Files
html/api/weval-ia-fast.php
2026-04-21 13:45:02 +02:00

3653 lines
238 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
function wevia_sanitize_public($t){$b=["Groq","Cerebras","SambaNova","Ollama","DeepSeek","Mistral","Together","Replicate","vLLM","Qwen","NVIDIA NIM","Cohere","OpenRouter","/opt/","/var/www/","/etc/","admin123","49222","11434","4001","3900","5890","204.168","95.216","151.80","10.1.0","root@","ssh -p","docker ps","nginx","postgresql","crontab"];foreach($b as $w)$t=str_ireplace($w,"WEVIA Engine",$t);return preg_replace("/\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b/","[infrastructure securisee]",$t);}
// === WEVIA INTERNAL API HELPER ===
// Fixes nginx SNI issue: https://127.0.0.1 resolves to analytics vhost
// Adding Host header forces correct vhost
function wevia_api($path) {
$ch = curl_init("https://127.0.0.1" . $path);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 15,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_HTTPHEADER => ["Host: weval-consulting.com"],
]);
$r = curl_exec($ch);
curl_close($ch);
return $r;
}
ini_set("display_errors","0");register_shutdown_function(function(){$e=error_get_last();if($e&&in_array($e["type"],[1,4,16,64])){header("Content-Type: application/json");http_response_code(200);echo json_encode(["response"=>"Service en maintenance","provider"=>"fallback"]);exit;}});
// wevia_mirofish_insights moved to cognitive-wire.php
// ═══ SOVEREIGN_FALLBACK — Ollama brain-v3 NEVER rate-limits ═══
function sovereign_fallback($prompt, $wireCtx) {
$body = json_encode(['model' => 'auto', 'messages' => [
['role' => 'system', 'content' => 'Tu es WEVIA, IA de WEVAL Consulting, cabinet transformation digitale Casablanca. WEVAL est REEL pas un groupe de musique. REGLE LIENS: Ne JAMAIS inventer de liens de telechargement (pas de /downloads/*.pdf). Si le user demande un PDF, genere le contenu dans ta reponse. Ne mets JAMAIS de lien fictif. ' . substr($wireCtx, 0, 2000)],
['role' => 'user', 'content' => $prompt]
], 'max_tokens' => 500, 'temperature' => 0.7]);
$ch = curl_init('http://127.0.0.1:4000/v1/chat/completions');
curl_setopt_array($ch, [CURLOPT_POST => true, CURLOPT_POSTFIELDS => $body,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 300]);
$resp = curl_exec($ch); curl_close($ch);
$d = json_decode($resp, true);
return $d['choices'][0]['message']['content'] ?? null;
}
set_time_limit(55);
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') { http_response_code(200); exit; }
if ($_SERVER['REQUEST_METHOD'] === 'GET') { die(json_encode(['status'=>'ok','engine'=>'WEVIA IA'])); }
$in = json_decode(file_get_contents('php://input'), true) ?: [];
$msg = trim($in['message'] ?? '');
// === WEVCODE / PLAN-EXECUTE SSE PASSTHROUGH (wave 202) ===
// Trigger: wevcode | plan-execute | /wevcode prefix
// Route to wevia-sse-orchestrator.php for streaming tools + multiagent
// Zero regression: only activates on explicit trigger, else falls through to JSON path
if ($msg && (preg_match('/\b(wevcode|plan[\s_-]*execute|plan[\s_-]*et[\s_-]*execute|plan[\s_-]*and[\s_-]*execute)\b/i', $msg) || strpos(ltrim($msg), '/wevcode') === 0)) {
header("Content-Type: text/event-stream");
header("Cache-Control: no-cache");
header("X-Accel-Buffering: no");
header("X-WEVIA-Route: plan-execute-sse");
@ob_implicit_flush(true);
while (ob_get_level()) @ob_end_flush();
$ch_sse = curl_init("https://127.0.0.1/api/wevia-sse-orchestrator.php");
curl_setopt_array($ch_sse, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode(["message" => $msg]),
CURLOPT_HTTPHEADER => ["Content-Type: application/json", "Host: weval-consulting.com"],
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_TIMEOUT => 120,
CURLOPT_WRITEFUNCTION => function($c, $chunk) {
// Apply public sanitizer on the stream to avoid leaks through the orchestrator
echo wevia_sanitize_public($chunk);
@flush();
return strlen($chunk);
},
]);
curl_exec($ch_sse);
curl_close($ch_sse);
exit;
}
// === FIN WEVCODE SSE PASSTHROUGH ===
if (strlen($msg) < 2) { die(json_encode(['error'=>'message required'])); }
// Image shortcut
if (preg_match('/(image|photo|visuel|genere.*image|futuris|logo|icone|illustration|dessin|artwork|banner|affiche)/i', $msg)) {
// Detect image style
$logo_style = preg_match('/logo|icone|icon|marque|brand/i', $msg);
$tableau_style = preg_match('/tableau|painting|artistique|art|abstract|canvas/i', $msg);
$banner_style = preg_match('/banner|banniere|affiche|poster|cover/i', $msg);
$illustration_style = preg_match('/illustration|dessin|draw|sketch|cartoon/i', $msg);
// Extract meaningful keywords (skip stopwords)
$stops = ['image','photo','visuel','genere','generer','une','des','pour','artistique','de','du','la','le','les','un','mon','ma','mes','cest','pas','que','qui'];
$words = preg_split('/\s+/', preg_replace('/[^a-zA-Z0-9\s]/u', '', strtolower($msg)));
$kw = array_values(array_filter($words, fn($w) => strlen($w) >= 3 && !in_array($w, $stops)));
$query = implode(',', array_slice($kw, 0, 3));
if (!$query) $query = 'landscape,nature';
$imgUrl = "https://image.pollinations.ai/prompt/" . rawurlencode($query . " professional high quality 4k") . "?width=" . ($logo_style ? "512&height=512" : ($banner_style ? "1280&height=480" : "1024&height=768")) . "&nologo=true&seed=" . rand(1,9999);
die(json_encode(["response"=>"Image generee par WEVIA Engine
![" . $query . "](" . $imgUrl . ")", "provider"=>"WEVIA IA", "mode"=>"image"]));
}
// ═══ PROVIDER CHAIN: Groq → Cerebras → S151 granite4 ═══
require_once '/opt/wevads/vault/credentials.php';
// === CLOUD FAST PATH (Ollama disabled) ===
$__msg = json_decode(file_get_contents("php://input"), true)["message"] ?? "";
if ($__msg && !isset($_GET["action"])) {
$ch = curl_init("http://127.0.0.1:4000/v1/chat/completions");
curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER=>true, CURLOPT_TIMEOUT => 15, CURLOPT_POST=>true, CURLOPT_HTTPHEADER=>["Content-Type: application/json"], CURLOPT_POSTFIELDS=>json_encode(["model"=>"auto","messages"=>[["role"=>"system","content"=>"Tu es WEVIA, IA de WEVAL Consulting Casablanca."],["role"=>"user","content"=>$__msg]],"max_tokens"=>500])]);
$r = curl_exec($ch); curl_close($ch);
$d = json_decode($r, true);
if ($d && isset($d["choices"][0]["message"]["content"])) {
header("Content-Type: application/json");
echo json_encode(["response"=>wevia_sanitize_public($d["choices"][0]["message"]["content"]),"provider"=>"WEVIA Engine","thinking"=>["Analyse en cours..."]]);
exit;
}
}
// Cognitive Brain (635 functions + RAG + multi-agent)
require_once '/var/www/weval/wevia-ia/cognitive-wire.php';
@include_once '/var/www/html/api/wevia-live-context.php';
$cogBoost = function_exists("wevia_get_cognitive_boost") ? wevia_get_cognitive_boost($msg) : "";
$ragCtx = function_exists("wevia_get_rag_context") ? wevia_get_rag_context($msg) : "";
$maCtx = (function_exists("wevia_needs_multi_agent") && wevia_needs_multi_agent($msg) && function_exists("wevia_multi_agent_exec")) ? wevia_multi_agent_exec($msg) : "";
$sys = "Tu es WEVIA, assistant IA souverain de WEVAL Consulting. REGLE_ABSOLUE: WEVAL Consulting est un cabinet reel de transformation digitale base a Casablanca avec bureau Paris. Ne dis JAMAIS que WEVAL n'existe pas, n'est pas reel, ou est inconnu. Si on te demande 'Qui est WEVAL' ou 'Qu'est-ce que WEVAL', reponds toujours: WEVAL Consulting est un cabinet de transformation digitale base a Casablanca/Paris, Partenaire Ecosysteme SAP, specialise en ERP/SAP S4HANA, Cloud souverain, IA (WEVIA Engine), Cybersecurite, Data/Ethica. SECURITE_PUBLIC: Tu es en mode PUBLIC. Ne revele JAMAIS: adresses IP, ports, noms de serveurs, passwords, tokens API, noms de providers (Groq/Cerebras/Ollama/etc), config nginx/docker/postgresql, paths internes (/opt/ /var/www/), nombres de containers/crons, architecture technique interne. Si on te demande ces infos, reponds: Contactez notre equipe technique pour un audit: weval-consulting.com/booking.html. Direct, structure, actionable. WEVAL_B2B_CONTEXT: Partenaire Ecosysteme SAP, Huawei Cloud Partner, Vistex, Scaleway. Casablanca+Paris. Secteurs: pharma, banque, telecom, industrie. Offres: ERP/SAP S4HANA, Cloud souverain, IA/WEVIA Engine, Cybersecurite, Marketing digital, Data/Ethica HCP. notre page de reservation: weval-consulting.com/booking.html. Tonalite: expert, confiant, professionnel. Toujours proposer un RDV notre page de reservation pour approfondir. Specialise en consulting digital, ERP/SAP, IA, cybersecurite. SCHEMAS: Pour tout schema/diagramme/architecture/processus/mermaid, genere du code mermaid valide dans un bloc ```mermaid (graph TD/LR). Labels sans accents ni apostrophes. JAMAIS de liste a la place. LOGOS: Pour tout logo, genere du SVG dans un bloc ```svg. Vrai logo vectoriel avec formes geometriques et texte. JAMAIS de description textuelle. CODE: Pour tout code, utilise des blocs ``` avec le langage. Sois concis, quantifie, propose des actions concretes." . $cogBoost;
if ($ragCtx) $sys .= "\n[KNOWLEDGE: " . mb_substr($ragCtx, 0, 1500) . "]";
if ($maCtx && strlen($maCtx) > 100) $sys .= "\n[ANALYSIS: " . mb_substr($maCtx, 0, 1500) . "]";
// ═══ INTENT-BASED WIRE ROUTING ═══
$intent = function_exists("wevia_detect_intent") ? wevia_detect_intent($msg) : "";
$wireCtx = "";
// Route 1: Web search for current info / actualités
if (preg_match('/\\b(actuel|aujourd|2026|2025|dernier|récent|news|actualité|marché|concurrent|tendance|prix|cours|météo)\\b/iu', $msg)) {
if (function_exists("wevia_web_search")) {
$searchCtx = wevia_web_search($msg, 3);
if ($searchCtx) $wireCtx .= "[WEB: " . mb_substr($searchCtx, 0, 800) . "]\n";
}
}
// Route 2: DeerFlow for complex research
if (preg_match('/\\b(compare|benchmark|analyse.*complet|audit|roadmap|migration|étude|recherche.*approfondi)\\b/iu', $msg) && strlen($msg) > 150) {
if (function_exists("wevia_deerflow_search")) {
$dfCtx = wevia_deerflow_search($msg);
if ($dfCtx) $wireCtx .= "[RESEARCH: " . mb_substr($dfCtx, 0, 1000) . "]\n";
}
}
// Route 3: Infrastructure / monitoring queries
if (preg_match('/\\b(serveur|docker|cpu|ram|disk|port|infra|monitoring|prometheus|uptime|health|status|panne)\\b/iu', $msg)) {
if (function_exists("wevia_system_health")) {
$healthCtx = wevia_system_health();
if ($healthCtx) $wireCtx .= "[INFRA: " . mb_substr($healthCtx, 0, 500) . "]\n";
}
}
// Route 4: CRM / contact queries
if (preg_match('/\\b(client|contact|prospect|lead|CRM|entreprise|société)\\b/iu', $msg)) {
if (function_exists("wevia_crm_search")) {
$crmCtx = wevia_crm_search($msg);
if ($crmCtx) $wireCtx .= "[CRM: $crmCtx]\n";
}
}
// Route 5: Enterprise / agent queries
if (preg_match('/\\b(agent|département|pipeline|paperclip|enterprise|équipe|effectif)\\b/iu', $msg)) {
if (function_exists("wevia_paperclip_context")) {
$pcCtx = wevia_paperclip_context();
if ($pcCtx) $wireCtx .= "[AGENTS: $pcCtx]\n";
}
}
// Route 6: Browser-Use for URL queries
if (preg_match('/\\b(visite|ouvre|url|site web|page web|navigue|browse)\\b/iu', $msg) && function_exists("wevia_needs_browser") && wevia_needs_browser($msg)) {
if (function_exists("wevia_browser_task")) {
$browseCtx = wevia_browser_task($msg);
if ($browseCtx) $wireCtx .= "[BROWSE: " . mb_substr($browseCtx, 0, 500) . "]\n";
}
}
// Route 7: Manager consensus for strategic decisions
if (function_exists("wevia_should_use_manager") && wevia_should_use_manager($msg)) {
if (function_exists("wevia_call_manager")) {
$mgrCtx = wevia_call_manager($msg);
if ($mgrCtx) $wireCtx .= "[MANAGER: " . mb_substr($mgrCtx, 0, 800) . "]\n";
}
}
// Route 8: Analytics / stats
if (preg_match('/\\b(analytics|statistique|trafic|visite|plausible|audience)\\b/iu', $msg)) {
if (function_exists("wevia_plausible_stats")) {
$statsCtx = wevia_plausible_stats();
if ($statsCtx) $wireCtx .= "[STATS: " . mb_substr(json_encode($statsCtx), 0, 500) . "]\n";
}
}
// ═══ EXTENDED WIRE ROUTES (Phase 2) ═══
// Route 9: Security / cyber queries → CrowdSec + Nuclei
if (preg_match('/\\b(sécurité|cyber|attaque|vulnérab|scan|threat|crowdsec|firewall|intrusion|alerte)\\b/iu', $msg)) {
if (function_exists("wevia_crowdsec_alerts")) {
$secCtx = wevia_crowdsec_alerts();
if ($secCtx) $wireCtx .= "[SECURITY: Trivy(/usr/local/bin/trivy) + Gitleaks(/usr/local/bin/gitleaks) + " . mb_substr(is_array($secCtx)?json_encode($secCtx):$secCtx, 0, 500) . "]\n";
}
}
// Route 10: Ollama local models for sovereign AI queries
if (preg_match('/\\b(modèle|model|ollama|local|souverain|llm|qwen|mistral|fine.?tun)\\b/iu', $msg)) {
if (function_exists("wevia_ollama_models")) {
$modCtx = wevia_ollama_models();
if ($modCtx) $wireCtx .= "[MODELS: " . mb_substr(is_array($modCtx)?json_encode($modCtx):$modCtx, 0, 400) . "]\n";
}
}
// Route 11: Ethica / pharma / HCP queries
if (preg_match('/\\b(ethica|pharma|médecin|hcp|docteur|spécialité|ordonnance|labo|santé|healthcare)\\b/iu', $msg)) {
$ethCtx = @wevia_api("/api/ethica-stats-api.php", false, $weval_internal_ctx);
$eth = json_decode($ethCtx, true);
if ($eth) $wireCtx .= "[ETHICA: " . mb_substr(json_encode($eth), 0, 500) . "]\n";
}
// Route 12: Langfuse traces for AI observability
if (preg_match('/\\b(trace|observ|langfuse|performance|latence|token|coût|usage)\\b/iu', $msg)) {
if (function_exists("wevia_langfuse_traces")) {
$lfCtx = wevia_langfuse_traces(3);
if ($lfCtx) $wireCtx .= "[TRACES: " . mb_substr(is_array($lfCtx)?json_encode($lfCtx):$lfCtx, 0, 400) . "]\n";
}
}
// Route 13: Vault / credentials health
if (preg_match('/\\b(vault|credential|secret|clé|token|mot de passe|expir)\\b/iu', $msg)) {
if (function_exists("wevia_vault_health")) {
$vCtx = wevia_vault_health();
if ($vCtx) $wireCtx .= "[VAULT: " . mb_substr(is_array($vCtx)?json_encode($vCtx):$vCtx, 0, 400) . "]\n";
}
}
// Route 14: OSS / open source tools installed
if (preg_match('/\\b(open.?source|oss|outil|tool|installé|/opt/|skill|capability)\\b/iu', $msg)) {
$ossCtx = @wevia_api("/api/oss-cache.json", false, $weval_internal_ctx);
$oss = json_decode($ossCtx, true);
if ($oss && is_array($oss)) $wireCtx .= "[OSS: " . count($oss) . " tools: " . mb_substr(implode(", ", array_column(array_slice($oss,0,10), "name")), 0, 300) . "]\n";
}
// Route 15: L99 / NonReg quality
if (preg_match('/\\b(test|nonreg|qualité|l99|regression|playwright|visual)\\b/iu', $msg)) {
$l99Ctx = @file_get_contents("/var/www/html/api/l99-results.json");
$l99 = json_decode($l99Ctx, true);
if ($l99) $wireCtx .= "[QUALITY: pass=" . ($l99["pass"]??"?") . "/" . ($l99["total"]??"?") . " score=" . ($l99["score"]??"?") . "%]\n";
}
// Route 16: Full system health composite
if (preg_match('/\\b(dashboard|overview|état|résumé|bilan|tout|global|complet)\\b/iu', $msg) && strlen($msg) < 60) {
if (function_exists("wevia_full_health")) {
$fhCtx = wevia_full_health();
if ($fhCtx) $wireCtx .= "[HEALTH: " . mb_substr(is_array($fhCtx)?json_encode($fhCtx):$fhCtx, 0, 600) . "]\n";
}
}
// ═══ OSS CAPABILITY ROUTES (Phase 3 — 18 missing needs) ═══
// Route 17: Skills / agent capabilities (629 skills in Qdrant)
if (preg_match('/\\b(skill|capability|capacité|compétence|savoir.?faire|agent.?skill)\\b/iu', $msg)) {
if (function_exists("wevia_get_rag_context")) {
$skillCtx = wevia_get_rag_context("skill capability " . mb_substr($msg, 0, 100), 5);
if ($skillCtx) $wireCtx .= "[SKILLS: " . mb_substr($skillCtx, 0, 600) . "]\n";
}
}
// Route 18: Automation / n8n / workflow / cron
if (preg_match('/\\b(automation|workflow|cron|tâche|scheduler|n8n|automatiser|planifier)\\b/iu', $msg)) {
$cronCtx = @wevia_api("/api/cron-status-api.php", false, $weval_internal_ctx);
$crons = json_decode($cronCtx, true);
if ($crons) $wireCtx .= "[CRONS: " . mb_substr(json_encode($crons), 0, 400) . "]\n";
if (function_exists("wevia_n8n_trigger")) {
$wireCtx .= "[N8N: available for workflow triggers]\n";
}
}
// Route 19: Code quality / DevOps / Git
if (preg_match('/\\b(code|git|commit|deploy|devops|CI|CD|qualité.*code|review|lint|refactor)\\b/iu', $msg)) {
$gitCtx = @shell_exec("cd /var/www/html && git log --oneline -5 2>/dev/null");
if ($gitCtx) $wireCtx .= "[GIT: " . trim(mb_substr($gitCtx, 0, 300)) . "]\n";
}
// Route 20: Scraping / data extraction
if (preg_match('/\\b(scrap|crawl|extract|données|data.*collect|spider|playwright|selenium)\\b/iu', $msg)) {
$scrapCtx = "Scrapy 4 spiders (S95 API), Playwright E2E, Browser-Use agent, BeautifulSoup4, Crawlee";
$wireCtx .= "[SCRAPING: $scrapCtx]\n";
}
// Route 21: ERP / SAP / consulting
if (preg_match('/\\b(ERP|SAP|S4.*HANA|consulting|intégr|migration|ABAP|Fiori|BTP)\\b/iu', $msg)) {
if (function_exists("wevia_get_rag_context")) {
$erpCtx = wevia_get_rag_context("SAP ERP consulting migration " . mb_substr($msg, 0, 80), 3);
if ($erpCtx) $wireCtx .= "[ERP_KB: " . mb_substr($erpCtx, 0, 500) . "]\n";
}
}
// Route 22: Email / deliverability / MTA
if (preg_match('/\\b(email|smtp|deliverabil|inbox|PMTA|kumo|postfix|warmup|bounce|spam)\\b/iu', $msg)) {
$emailCtx = "PMTA(25+587) KumoMTA(8010) Postfix(2525+2526) — send tools S95. 646 configs, 9 winners. Warmup engine active.";
$wireCtx .= "[EMAIL: $emailCtx]\n";
}
// Route 23: MCP Protocol / tool discovery
if (preg_match('/\\b(MCP|protocol|tool.*discovery|registry|endpoint|API.*list)\\b/iu', $msg)) {
$regCtx = @wevia_api("/api/registry.php", false, $weval_internal_ctx);
$reg = json_decode($regCtx, true);
if ($reg) {
$summary = [];
foreach ($reg as $k => $v) { if (is_array($v) && isset($v["total"])) $summary[] = "$k:{$v['total']}"; }
$wireCtx .= "[REGISTRY: " . implode(", ", $summary) . "]\n";
}
}
// Route 24: Sovereign / privacy / RGPD / open source philosophy
if (preg_match('/\\b(souverain|sovereign|RGPD|GDPR|privacy|open.?source|vendor.?lock|indépendance)\\b/iu', $msg)) {
$sovCtx = "Philosophie WEVAL: souveraineté first. 15 providers IA à 0€. Ollama local. Qdrant souverain. SearXNG. Zero vendor lock-in. 146 tools dont 97 intégrés, 45 wirés, 31 free tier.";
$wireCtx .= "[SOVEREIGN: $sovCtx]\n";
}
// ═══ FREE TIER DEPLOYMENT ROUTES ═══
// Route 25: GPU / free tier / deployment queries
if (preg_match('/\\b(GPU|colab|kaggle|hugging.?face|space|deploy|free.?tier|cloud.?gratuit|fine.?tun|train)\\b/iu', $msg)) {
$gpuCtx = "FREE GPU: Colab(T4/A100), Kaggle(P100 30h/sem), HF Spaces(16GB). "
. "DEPLOYED: RAGFlow(HF Space ready), Unsloth+LLaMA-Factory(Colab notebooks ready). "
. "LOCAL: Whisper.cpp(S204 CPU), Ollama(6 models :11434). "
. "CLOUD: Oracle(4 ARM 24GB free), Railway(500h/mois), Render(free tier).";
$wireCtx .= "[GPU_FREE: $gpuCtx]\n";
}
// Route 26: Voice / audio / transcription
if (preg_match('/\\b(voix|voice|audio|transcri|speech|whisper|micro|enregistr)\\b/iu', $msg)) {
if (function_exists("wevia_whisper_transcribe")) {
$wireCtx .= "[VOICE: Whisper.cpp installed /opt/whisper.cpp — CPU speech-to-text, zero API cost]\n";
}
}
// ═══ ENRICHED ROUTES (Phase 4 — orphan APIs + deep capabilities) ═══
// Route 27: Vision / image analysis
if (preg_match('/\\b(image|photo|vision|voir|analyser.*image|screenshot|capture)\\b/iu', $msg)) {
if (function_exists("wevia_vision_analyze")) {
$wireCtx .= "[VISION: wevia_vision_analyze available — Ollama multimodal + wevia-vision-vl.php]\n";
}
}
// Route 28: Database / data queries
if (preg_match('/\\b(database|base.*données|table|PostgreSQL|requête|SQL|data.*base|6\\.65M|contacts)\\b/iu', $msg)) {
if (function_exists("wevia_db_stats")) {
$dbCtx = wevia_db_stats();
if ($dbCtx) $wireCtx .= "[DB: " . mb_substr(is_array($dbCtx)?json_encode($dbCtx):$dbCtx, 0, 400) . "]\n";
}
}
// Route 29: Provider / model management
if (preg_match('/\\b(provider|fournisseur|API.*key|clé.*API|cerebras|groq|deepseek|mistral|sambanova)\\b/iu', $msg)) {
if (function_exists("wevia_list_providers")) {
$provCtx = wevia_list_providers();
if ($provCtx) $wireCtx .= "[PROVIDERS: " . mb_substr(is_array($provCtx)?json_encode($provCtx):$provCtx, 0, 400) . "]\n";
}
}
// Route 30: Capabilities / what can WEVIA do
if (preg_match('/\\b(capable|capacité|capability|que.*sais|que.*peux|fonctionnalité|feature)\\b/iu', $msg)) {
if (function_exists("wevia_list_capabilities")) {
$capCtx = wevia_list_capabilities();
if ($capCtx) $wireCtx .= "[CAPABILITIES: $capCtx]\n";
}
}
// Route 31: Deep analysis / brain analyze
if (preg_match('/\\b(analyse.*profond|deep.*analysis|audit.*code|revue.*code|diagnos)\\b/iu', $msg) && strlen($msg) > 100) {
if (function_exists("wevia_brain_analyze")) {
$analyCtx = wevia_brain_analyze($msg);
if ($analyCtx) $wireCtx .= "[ANALYSIS: " . mb_substr($analyCtx, 0, 600) . "]\n";
}
}
// Route 32: OSS ecosystem complete overview
if (preg_match('/\\b(écosystème|ecosystem|stack.*complet|tech.*radar|tools.*hub|146.*tools|690.*sources)\\b/iu', $msg)) {
$ecoCtx = "WEVAL Ecosystem: 146 tools hub, 690 GitHub sources, 629 skills, 554 wirés, 60 prod OSS. "
. "22 Docker, 19 crons, 15 AI providers (0€), 13765 Qdrant vectors. "
. "3 HF Spaces (ragflow/mlflow/whisper), 2 Colab notebooks (unsloth/llama-factory). "
. "Whisper.cpp CPU local. 477L cognitive-wire, 37+ functions, 28+ wires.";
$wireCtx .= "[ECOSYSTEM: $ecoCtx]\n";
}
// ═══ ORPHAN API ACTIVATION (Phase 5) ═══
// Route 33: WEVIA Tools — all tool extensions
if (preg_match('/\\b(outil|tool|extension|plugin|module|fonctionnalit)\\b/iu', $msg)) {
$toolsCtx = @wevia_api("/api/wevia-tools.php", false, $weval_internal_ctx);
$tools = json_decode($toolsCtx, true);
if ($tools) $wireCtx .= "[TOOLS: " . mb_substr(is_array($tools)?json_encode($tools):$tools, 0, 400) . "]\n";
}
// Route 34: WEVIA Agent Loop — autonomous agent execution
if (preg_match('/\\b(agent.*loop|autonome|auto.*exécut|boucle|itérat|agent.*continu)\\b/iu', $msg)) {
$wireCtx .= "[AGENT_LOOP: wevia-agent-loop.php (302L) available — autonomous agent execution with feedback loops]\n";
}
// Route 35: Ethica API + Consent — full pharma pipeline
if (preg_match('/\\b(ethica|HCP|médecin|pharmacien|consent|opt.?in|pilot|campagne.*pharma)\\b/iu', $msg)) {
$ethApiCtx = @wevia_api("/api/ethica-api.php?action=stats", false, $weval_internal_ctx);
$eth = json_decode($ethApiCtx, true);
if ($eth) $wireCtx .= "[ETHICA_FULL: " . mb_substr(json_encode($eth), 0, 400) . "]\n";
$wireCtx .= "[CONSENT: consent.wevup.app LIVE, ethica-consent-api.php + ethica-collector-api.php available]\n";
}
// Route 36: Blade IA — remote agent status
if (preg_match('/\\b(blade|razer|windows|GPU.*local|desktop.*agent)\\b/iu', $msg)) {
$wireCtx .= "[BLADE: Blade IA v4.2 — Agent Razer GLM-5, Sentinel v2.4, 34 caps. Status: OFFLINE (needs Windows reboot)]\n";
}
// Route 37: S151 / OpenClaw / sovereign inference
if (preg_match('/\\b(S151|OVH|openclaw|151\\.80|sovereign.*model|local.*inference|tracking)\\b/iu', $msg)) {
$wireCtx .= "[S151: 151.80.235.110 OVH tracking server. OpenClaw+Ollama Docker (qwen2.5:3b). Domain: culturellemejean.charity. 46% disk.]\n";
}
// Route 38: WEVIA Sovereign Proxy — multi-provider routing
if (preg_match('/\\b(proxy|routing|failover|fallback|multi.?provider|chaîne.*provider)\\b/iu', $msg)) {
$proxyCtx = @wevia_api("/api/wevia-sovereign-proxy.php?action=status", false, $weval_internal_ctx);
$px = json_decode($proxyCtx, true);
if ($px) $wireCtx .= "[PROXY: " . mb_substr(json_encode($px), 0, 300) . "]\n";
else $wireCtx .= "[PROXY: wevia-sovereign-proxy.php — Groq→Cerebras→DeepSeek→Mistral→SambaNova→S151 failover chain]\n";
}
// ═══ DEAD CODE FIX — Wire remaining functions into routes ═══
// Route 39: MiroFish CEO intelligence
if (preg_match('/\\b(CEO|stratégi|intelligence|insight|décision|direction|mirofish)\\b/iu', $msg)) {
if (function_exists("wevia_mirofish_insights")) {
$mfCtx = wevia_mirofish_insights($msg);
if ($mfCtx) $wireCtx .= "[CEO: " . mb_substr($mfCtx, 0, 400) . "]\n";
}
}
// Enrich Route 18 (automation) with n8n trigger + Mattermost notify
if (preg_match('/\\b(notification|alerter|notifier|mattermost|slack|message.*équipe)\\b/iu', $msg)) {
if (function_exists("wevia_mm_notify")) {
$wireCtx .= "[NOTIFY: wevia_mm_notify(channel, message) available — Mattermost :8065]\n";
}
}
// Enrich Route 28 (DB) with ClickHouse analytics
if (preg_match('/\\b(clickhouse|OLAP|analytics.*db|warehouse|plausible.*data)\\b/iu', $msg)) {
if (function_exists("wevia_clickhouse_query")) {
$wireCtx .= "[CLICKHOUSE: OLAP analytics backend, wevia_clickhouse_query available]\n";
}
}
// Enrich monitoring with Uptime Kuma detailed
if (preg_match('/\\b(uptime|kuma|disponibilité|SLA|downtime|12.*services)\\b/iu', $msg)) {
if (function_exists("wevia_uptime_status")) {
$ukCtx = wevia_uptime_status();
if ($ukCtx) $wireCtx .= "[UPTIME: " . mb_substr(is_array($ukCtx)?json_encode($ukCtx):$ukCtx, 0, 400) . "]\n";
}
}
// Enrich monitoring with Loki logs
if (preg_match('/\\b(log|loki|erreur|journal|syslog|nginx.*log|access.*log)\\b/iu', $msg)) {
if (function_exists("wevia_loki_logs")) {
$lokiCtx = wevia_loki_logs("error", 5);
if ($lokiCtx) $wireCtx .= "[LOGS: " . mb_substr(is_array($lokiCtx)?json_encode($lokiCtx):$lokiCtx, 0, 400) . "]\n";
}
}
// Prometheus direct queries
if (preg_match('/\\b(prometheus|métriq|metric|cpu.*usage|memory.*usage|node.*export)\\b/iu', $msg)) {
if (function_exists("wevia_prometheus_query")) {
$promCtx = wevia_prometheus_query("up");
if ($promCtx) $wireCtx .= "[PROMETHEUS: " . mb_substr(is_array($promCtx)?json_encode($promCtx):$promCtx, 0, 300) . "]\n";
}
}
// Ollama generate (local model inference)
if (preg_match('/\\b(génère.*local|ollama.*génère|inference.*local|weval.?brain|brain.*v2)\\b/iu', $msg)) {
if (function_exists("wevia_ollama_generate")) {
$wireCtx .= "[OLLAMA_GEN: wevia_ollama_generate available — auto, qwen3:8b, mistral local]\n";
}
}
// LAST 3: Flowise + Analytics deep
if (preg_match('/flowise|chatflow/i', $msg)) { $wireCtx .= "[FLOWISE: wevia_flowise_run + predict available. Port 3001 (needs restart)]\n"; }
if (preg_match('/analytics.*detail|bounce|session.*deep/i', $msg) && function_exists("wevia_analytics")) { $a = wevia_analytics("7d"); if ($a) $wireCtx .= "[ANALYTICS_DEEP: " . mb_substr(is_array($a)?json_encode($a):$a, 0, 300) . "]\n"; }
// ═══ AUTONOMOUS EXECUTION ROUTES (Phase 6) ═══
// Route 39: Autonomous agent execution via WEVIA Agent Loop
if (preg_match('/\\b(exécute|execute|lance|run|fais.*autonome|agent.*loop|boucle.*agent|auto.*task)\\b/iu', $msg)) {
$goal = preg_replace('/^.*(exécute|lance|run|fais)\\s*/iu', '', $msg);
$agentCtx = wevia_api("/api/wevia-agent-loop.php?agent=devops&goal=" . urlencode(mb_substr($goal,0,200)));
$al = json_decode($agentCtx, true);
if ($al && isset($al["result"])) $wireCtx .= "[AGENT_EXEC: " . mb_substr($al["result"], 0, 600) . "]\n";
else $wireCtx .= "[AGENT_LOOP: 4 agents available (devops,ethica,security,monitor). Use: /api/wevia-agent-loop.php?agent=X&goal=Y]\n";
}
// Route 40: Blade IA relay (when online)
if (preg_match('/\\b(blade|GPU.*local|razer|desktop.*IA|windows.*agent|glm)\\b/iu', $msg)) {
$bladeCtx = wevia_api("/api/blade-api.php?action=status", false, $weval_internal_ctx);
$bl = json_decode($bladeCtx, true);
if ($bl && isset($bl["status"])) $wireCtx .= "[BLADE: " . mb_substr(json_encode($bl), 0, 300) . "]\n";
else $wireCtx .= "[BLADE: OFFLINE — Razer Blade IA v4.2, GLM-5 GPU, 34 capabilities. Needs Windows reboot.]\n";
}
// Route 41: WEVIA Master API — composite dashboard
if (preg_match('/\\b(master|dashboard.*complet|tout.*status|synthèse.*complète|all.*systems)\\b/iu', $msg)) {
$masterCtx = @wevia_api("/api/wevia-master-api.php?dashboard", false, $weval_internal_ctx);
$ma = json_decode($masterCtx, true);
if ($ma) $wireCtx .= "[MASTER: " . mb_substr(json_encode($ma), 0, 800) . "]\n";
}
// Route 43: NocoDB deployed tool
if (preg_match('/\\b(nocodb|airtable|spreadsheet|base.*données.*simple|tableau)\\b/iu', $msg)) {
$nocoCode = @file_get_contents("http://127.0.0.1:8080/api/v1/health");
if (!$nocoCode) $nocoCode = @file_get_contents("http://127.0.0.1:8081/api/v1/health");
$wireCtx .= "[NOCODB: " . ($nocoCode ? "LIVE sur S204 Docker" : "Docker UP, initialising") . " — Airtable alternative souveraine, API REST, 0€]\n";
}
// Route 44: Dormant / available / potential capabilities
if (preg_match('/\\b(dormant|disponible|potentiel|template|ECC|SuperClaude|persona|inactif|idle|capability.*list)\\b/iu', $msg)) {
$dormCtx = "Paperclip: 716 agents (566 active, 150 idle). ";
$dormCtx .= "DeerFlow: 545 skills indexed. ";
$dormCtx .= "Templates: ECC(code reviewers), SC(SuperClaude modes), Persona(consultants). ";
$dormCtx .= "Real dormants: CrewAI, AutoGen, ListMonk, NoVNC, Amass — installables on demand. ";
$dormCtx .= "All tracked in enterprise-model.html + Paperclip DB + Registry.";
$wireCtx .= "[DORMANT: $dormCtx]\n";
}
// ═══ DEEP INTEGRATION ROUTES (Opus Phase 7) ═══
// Route 44: Paperclip DEEP — departments, tasks, budgets
if (preg_match('/\\b(département|department|budget|task|mission|approbation|approval|organi)\\b/iu', $msg)) {
if (function_exists("wevia_paperclip_deep")) {
$deepPc = wevia_paperclip_deep($msg);
if ($deepPc) $wireCtx .= "[PAPERCLIP_DEEP: $deepPc]\n";
}
}
// Route 45: DeerFlow DEEP — assistants, research threads
if (preg_match('/\\b(assistant|thread|recherche.*deep|deep.*research|langgraph)\\b/iu', $msg)) {
if (function_exists("wevia_deerflow_assistants")) {
$dfAssist = wevia_deerflow_assistants();
if ($dfAssist) $wireCtx .= "[DEERFLOW_DEEP: $dfAssist]\n";
}
}
// Route 46: Registry LIVE — real-time system snapshot
if (preg_match('/\\b(registr|inventaire|système.*complet|all.*systems|état.*global)\\b/iu', $msg)) {
if (function_exists("wevia_registry_live")) {
$regLive = wevia_registry_live();
if ($regLive) $wireCtx .= "[REGISTRY_LIVE: $regLive]\n";
}
}
// ═══ TIER 1-3 API ROUTES (Opus Phase 8 — complete parity) ═══
// Route 47: Blade IA — brain + ops + agent
if (preg_match('/\\b(blade|razer|GPU.*local|desktop.*IA|glm|sentinel.*agent|watchdog)\\b/iu', $msg)) {
$bladeCtx = wevia_api("/api/blade-api.php?action=status", false, $weval_internal_ctx);
$bl = json_decode($bladeCtx, true);
$hb = json_decode(@file_get_contents("/var/www/html/api/blade-tasks/heartbeat.json"), true);
$wireCtx .= "[BLADE: " . ($bl ? json_encode($bl) : "API auth needed") . " | Heartbeat: " . ($hb ? $hb["ts"] . " CPU:" . $hb["cpu"] . " RAM:" . $hb["ram"] : "no data") . "]\n";
}
// Route 48: WeDroid — diagnostics + brain
if (preg_match('/\\b(wedroid|droid|diagnos|fix.*auto|backend.*repair|S95.*exec)\\b/iu', $msg)) {
$wireCtx .= "[WEDROID: wedroid-brain-api.php (35KB) — backend diagnostics, S95 chain exec, 192 Arsenal screens. Active via Droid endpoint.]\n";
}
// Route 49: ClawCode — sovereign coding
if (preg_match('/\\b(claw.*code|coding.*souverain|code.*assist|rust.*port|claude.*code.*local)\\b/iu', $msg)) {
$clawStatus = @file_get_contents("http://127.0.0.1:3900/");
$wireCtx .= "[CLAWCODE: Port 3900 " . ($clawStatus ? "LIVE" : "checking") . " — Rust port of Claude Code harness, sovereign coding assistant]\n";
}
// Route 50: ADX Bridge — WEVADS connection
if (preg_match('/\\b(adx|wevads|bridge|campaign|email.*market|deliverabil)\\b/iu', $msg)) {
$wireCtx .= "[ADX: adx-bridge.php (25KB) — WEVADS bridge, campaign management, 6.65M contacts, Brain Engine 646 configs]\n";
}
// Route 51: AutoLearn — RAG auto-enrichment
if (preg_match('/\\b(autolearn|auto.*learn|enrichi.*auto|rag.*auto|apprentissage)\\b/iu', $msg)) {
$wireCtx .= "[AUTOLEARN: autolearn.php — automatic RAG enrichment from conversations, Qdrant injection, skill discovery]\n";
}
// Route 52: AI Benchmark — live comparisons
if (preg_match('/\\b(benchmark|compar.*modèle|perf.*IA|latence.*provider|speed.*test)\\b/iu', $msg)) {
$benchCtx = @wevia_api("/api/ai-benchmark-live.php?action=latest", false, $weval_internal_ctx);
$wireCtx .= "[BENCHMARK: " . ($benchCtx ? mb_substr($benchCtx,0,300) : "ai-benchmark-live.php — real-time LLM comparison across 15 providers") . "]\n";
}
// Route 53: CRM — deals + contacts
if (preg_match('/\\b(crm|deal|opportunité|lead|pipeline.*vente|contact.*client|twenty)\\b/iu', $msg)) {
$crmCtx = @file_get_contents("http://127.0.0.1:3000/api");
$wireCtx .= "[CRM: Twenty CRM :3000 " . ($crmCtx ? "LIVE" : "checking") . " — crm-api.php (14KB), deals, PDF gen, séquences outbound]\n";
}
// Route 54: Anthropic + OpenAI proxy
if (preg_match('/\\b(anthropic|openai|proxy.*claude|proxy.*gpt|compatible.*api)\\b/iu', $msg)) {
$wireCtx .= "[PROXY: wevia-anthropic.php (Claude proxy) + wevia-openai.php (OpenAI-compatible) — sovereign multi-provider routing]\n";
}
// ═══ FINAL WIRE ROUTES (Opus Phase 9 — total coverage) ═══
// Route 55: Browser-Use automation
if (preg_match('/\\b(browser.*use|navigateur.*auto|web.*automat|scrape.*live|playwright.*agent)\\b/iu', $msg)) {
$wireCtx .= "[BROWSER_USE: browser-use-api.php — agent navigateur web automatisé. Cloné /opt/browser-use/. Playwright + headless Chromium.]\n";
}
// Route 56: Agent fleet catalog + status
if (preg_match('/\\b(fleet|catalogue.*agent|status.*agent|monitoring.*agent|agent.*alive|alive)\\b/iu', $msg)) {
$catCtx = @wevia_api("/api/agents-catalog.php", false, $weval_internal_ctx);
$statCtx = @wevia_api("/api/agents-status.php", false, $weval_internal_ctx);
$wireCtx .= "[FLEET: agents-catalog.php + agents-status.php — " . ($catCtx ? "catalog LIVE" : "catalog available") . " | " . ($statCtx ? "status LIVE" : "status available") . "]\n";
}
// Route 57: CodeRabbit code review
if (preg_match('/\\b(coderabbit|code.*review|review.*pull|PR.*review|webhook.*github)\\b/iu', $msg)) {
$wireCtx .= "[CODERABBIT: coderabbit-webhook.php — automated code review on GitHub PRs, webhook integration]\n";
}
// Route 58: Chat proxy multi-provider
if (preg_match('/\\b(chat.*proxy|multi.*chat|proxy.*llm|relay.*chat|forward.*chat)\\b/iu', $msg)) {
$wireCtx .= "[CHAT_PROXY: chat-proxy.php (13KB) — multi-provider chat relay, load balancing across 15 providers, 0€]\n";
}
// Route 59: Tool extensions + bench
if (preg_match('/\\b(tool.*ext|extension.*outil|plugin.*tool|bench.*suite|benchmarking.*suite)\\b/iu', $msg)) {
$wireCtx .= "[TOOLS: wevia-tool-extensions.php (203L) + wevia-bench.php — tool registry + benchmarking suite]\n";
}
// Route 60: WEVIA MASTER composite (everything at once)
if (preg_match('/\\b(master.*complet|opus.*parity|tout.*en.*un|full.*stack|résumé.*total|capacité.*totale)\\b/iu', $msg)) {
$masterCtx = "WEVIA MASTER: 60 routes chatbot (Opus) + 124 routes dispatcher (C2). ";
$masterCtx .= "32 wire functions. 716 agents Paperclip. 2 assistants DeerFlow. 13765 vectors Qdrant. ";
$masterCtx .= "25 Docker. 19 crons. 15 AI providers 0€. Streaming SSE Cerebras Qwen-235B. ";
$masterCtx .= "3 HF Spaces. NocoDB :8234 LIVE. Whisper.cpp CPU. ";
$masterCtx .= "NonReg 152/153 (99%).";
$wireCtx .= "[MASTER: $masterCtx]\n";
}
// ═══ CYBER ADVANCED ROUTES (Opus 5avr) ═══
// Route 61: Trivy container vulnerability scan
if (preg_match('/\\b(trivy|container.*vuln|docker.*scan|image.*vuln|CVE.*docker)\\b/iu', $msg)) {
if (function_exists("wevia_trivy_scan")) {
$trivyCtx = wevia_trivy_scan("all");
if ($trivyCtx) $wireCtx .= "[TRIVY: $trivyCtx]\n";
}
}
// Route 62: Gitleaks secret scanning
if (preg_match('/\\b(gitleaks|secret.*scan|credential.*leak|key.*exposed|fuite.*secret)\\b/iu', $msg)) {
if (function_exists("wevia_gitleaks_scan")) {
$glCtx = wevia_gitleaks_scan("/var/www/html");
if ($glCtx) $wireCtx .= "[GITLEAKS: $glCtx]\n";
}
}
// Route 63: Nuclei vulnerability scan
if (preg_match('/\\b(nuclei|vuln.*scan|pentest|owasp|cve.*check)\\b/iu', $msg)) {
if (function_exists("wevia_nuclei_scan")) {
$nucleiCtx = wevia_nuclei_scan("weval-consulting.com");
if ($nucleiCtx) $wireCtx .= "[NUCLEI: $nucleiCtx]\n";
}
}
// Route 64: CrowdSec advanced (decisions + bouncers + metrics)
if (preg_match('/\\b(crowdsec.*avancé|ban.*ip|bouncer|décision.*sécurité|blocked.*ip)\\b/iu', $msg)) {
if (function_exists("wevia_crowdsec_advanced")) {
$csAdv = wevia_crowdsec_advanced();
if ($csAdv) $wireCtx .= "[CROWDSEC_ADV: $csAdv]\n";
}
}
// Route 65: AEGIS security API
if (preg_match('/\\b(aegis|agent.*security|sécurité.*agent|shield)\\b/iu', $msg)) {
if (function_exists("wevia_aegis_status")) {
$aegisCtx = wevia_aegis_status();
if ($aegisCtx) $wireCtx .= "[AEGIS: $aegisCtx]\n";
}
}
// Route 66: Full Cyber Pipeline (audit complet)
if (preg_match('/\\b(audit.*cyber|cyber.*pipeline|pentest.*complet|sécurité.*complète|full.*security|scan.*total)\\b/iu', $msg)) {
if (function_exists("wevia_cyber_pipeline")) {
$cyberPipe = wevia_cyber_pipeline();
if ($cyberPipe) $wireCtx .= "[CYBER_PIPELINE: $cyberPipe]\n";
}
}
// ═══ ROUTES 67-76 — Opus Session 5 avril 07h ═══
// Route 67: WEVIA Autonomous Engine — C2 autonomous actions
if (preg_match('/\b(autonom|self.*heal|auto.*repair|engine.*autonom|cortex.*run)\b/iu', $msg)) {
$autoCtx = @wevia_api("/api/wevia-autonomous.php?status", false, $weval_internal_ctx);
if ($autoCtx) $wireCtx .= "[AUTONOMOUS: $autoCtx]\n";
}
// Route 68: Realtime Status — live system snapshot
if (preg_match('/\b(realtime|temps.*r[ée]el|live.*status|snapshot|instant)\b/iu', $msg)) {
$rtCtx = @wevia_api("/api/realtime-status.php", false, $weval_internal_ctx);
if ($rtCtx) $wireCtx .= "[REALTIME: " . substr($rtCtx, 0, 500) . "]\n";
}
// Route 69: Infra Monitor — deep infrastructure analysis
if (preg_match('/\b(infra.*monitor|monitoring.*infra|server.*health|serveur.*sant[ée])\b/iu', $msg)) {
$infraCtx = @wevia_api("/api/infra-monitor-api.php?action=status", false, $weval_internal_ctx);
if ($infraCtx) $wireCtx .= "[INFRA_MONITOR: " . substr($infraCtx, 0, 500) . "]\n";
}
// Route 70: WEVADS v2 Engine — email marketing platform
if (preg_match('/\b(wevads.*engine|campaign|campagne|email.*market|arsenal.*engine)\b/iu', $msg)) {
$wevadsCtx = @file_get_contents("http://10.1.0.3:5890/api/wevads-v2-engine.php?action=status");
if ($wevadsCtx) $wireCtx .= "[WEVADS_ENGINE: " . substr($wevadsCtx, 0, 500) . "]\n";
}
// Route 71: NonReg Opus — extended test intelligence
if (preg_match('/\b(nonreg.*opus|test.*intelli|qualit[ée].*avanc|regression.*deep)\b/iu', $msg)) {
$nrCtx = @wevia_api("/api/nonreg-opus.php?action=latest", false, $weval_internal_ctx);
if ($nrCtx) $wireCtx .= "[NONREG_OPUS: " . substr($nrCtx, 0, 500) . "]\n";
}
// Route 72: OSS Discovery API — trending open source
if (preg_match('/\b(oss.*discover|open.*source.*trend|github.*trend|trending.*tool)\b/iu', $msg)) {
$ossCtx = @wevia_api("/api/oss-discovery.php?action=trending", false, $weval_internal_ctx);
if ($ossCtx) $wireCtx .= "[OSS_DISCOVERY: " . substr($ossCtx, 0, 500) . "]\n";
}
// Route 73: WEVIA Brain API — cognitive analysis
if (preg_match('/\b(brain.*api|cerveau|cognitif|analyse.*deep|reasoning)\b/iu', $msg)) {
$brainCtx = @wevia_api("/api/wevia-brain.php?action=status", false, $weval_internal_ctx);
if ($brainCtx) $wireCtx .= "[BRAIN_API: " . substr($brainCtx, 0, 500) . "]\n";
}
// Route 74: WEVIA Artifact Host — code artifacts
if (preg_match('/\b(artifact|artefact|code.*host|sandbox|preview)\b/iu', $msg)) {
$artCtx = @wevia_api("/api/wevia-artifact-host.php?action=list", false, $weval_internal_ctx);
if ($artCtx) $wireCtx .= "[ARTIFACTS: " . substr($artCtx, 0, 300) . "]\n";
}
// Route 75: WEVIA Capabilities — full capability registry
if (preg_match('/\b(capabilit|capacit[ée]|comp[ée]tence|skill.*regist|que.*sais.*faire)\b/iu', $msg)) {
$capCtx = @wevia_api("/api/wevia-capabilities.php?action=list", false, $weval_internal_ctx);
if ($capCtx) $wireCtx .= "[CAPABILITIES: " . substr($capCtx, 0, 500) . "]\n";
}
// Route 76: WEVIA CORTEX — autonomous brain status
if (preg_match('/\b(cortex|surveillance.*autonom|monitoring.*brain|health.*autonom)\b/iu', $msg)) {
$cortexLog = @file_get_contents("/var/log/wevia-cortex.log");
if ($cortexLog) {
$lastLines = implode("\n", array_slice(explode("\n", trim($cortexLog)), -5));
$wireCtx .= "[CORTEX: $lastLines]\n";
}
}
// ═══ ROUTES 77-86 — Opus Session 5 avril 07h15 ═══
// Route 77: Blade Brain — deep cognitive orchestration (40KB)
if (preg_match('/\b(blade.*brain|orchestr.*cogni|blade.*deep|planif.*blade)\b/iu', $msg)) {
$bbCtx = @wevia_api("/api/blade-brain.php?action=status", false, $weval_internal_ctx);
if ($bbCtx) $wireCtx .= "[BLADE_BRAIN: " . substr($bbCtx, 0, 500) . "]\n";
}
// Route 78: Blade Ops — deployment + rollback (28KB)
if (preg_match('/\b(blade.*ops|deploy.*blade|rollback|blade.*operation)\b/iu', $msg)) {
$boCtx = @wevia_api("/api/blade-ops-api.php?action=status", false, $weval_internal_ctx);
if ($boCtx) $wireCtx .= "[BLADE_OPS: " . substr($boCtx, 0, 500) . "]\n";
}
// Route 79: WEVAL Manager — multi-agent consensus (36KB)
if (preg_match('/\b(manager.*consensus|d[ée]cision.*multi|vote.*agent|consensus.*strat)\b/iu', $msg)) {
$wmCtx = @wevia_api("/api/weval-manager.php?action=status", false, $weval_internal_ctx);
if ($wmCtx) $wireCtx .= "[MANAGER: " . substr($wmCtx, 0, 500) . "]\n";
}
// Route 80: MCP Protocol — tool discovery + execution (15KB)
if (preg_match('/\b(mcp.*proto|model.*context|tool.*discover|protocol.*tool)\b/iu', $msg)) {
$mcpCtx = @wevia_api("/api/mcp.php?action=list", false, $weval_internal_ctx);
if ($mcpCtx) $wireCtx .= "[MCP: " . substr($mcpCtx, 0, 500) . "]\n";
}
// Route 81: WEVIA LIFE — email intelligence (read/analyze/send)
if (preg_match('/\b(wevia.*life|email.*intelli|lire.*mail|analyser.*mail|inbox)\b/iu', $msg)) {
$lifeCtx = @wevia_api("/products/wevialife-api.php?action=stats", false, $weval_internal_ctx);
if ($lifeCtx) $wireCtx .= "[WEVIA_LIFE: " . substr($lifeCtx, 0, 500) . "]\n";
}
// Route 82: Whisper STT — speech to text
if (preg_match('/\b(whisper|transcri|speech.*text|audio.*texte|vocal.*texte)\b/iu', $msg)) {
$whisperOk = file_exists("/opt/whisper.cpp/build/bin/main");
$wireCtx .= "[WHISPER: " . ($whisperOk ? "Compilé OK, modèle ggml-base.bin 148MB, /opt/whisper.cpp/" : "Non installé") . "]\n";
}
// Route 83: Twenty CRM Deep — deals + contacts + pipeline
if (preg_match('/\b(twenty.*crm|deal|pipeline.*crm|contact.*crm|opportunit)\b/iu', $msg)) {
$crmCtx = @file_get_contents("http://127.0.0.1:3000/api");
if ($crmCtx) $wireCtx .= "[TWENTY_CRM: " . substr($crmCtx, 0, 300) . "]\n";
}
// Route 84: Mattermost — team communication
if (preg_match('/\b(mattermost|team.*chat|canal|channel.*equipe)\b/iu', $msg)) {
$mmCtx = @file_get_contents("http://127.0.0.1:8065/api/v4/system/ping");
if ($mmCtx) $wireCtx .= "[MATTERMOST: LIVE — $mmCtx]\n";
}
// Route 85: WEVIA CORTEX Deep — full autonomous history
if (preg_match('/\b(cortex.*hist|history.*autonom|log.*cortex|journal.*cortex)\b/iu', $msg)) {
$cortexFull = @file_get_contents("/var/log/wevia-cortex.log");
if ($cortexFull) {
$lines = array_slice(explode("\n", trim($cortexFull)), -15);
$wireCtx .= "[CORTEX_HISTORY: " . implode(" | ", $lines) . "]\n";
}
}
// Route 86: INCONSCIENT COLLECTIF — shared memory across ALL Claude instances
// This is the HIVE MIND: Qdrant wevia_learnings + wevia_memory + wevia_kb combined
if (preg_match('/\b(inconscient|collectif|hive|swarm|m[ée]moire.*partag|shared.*memory|conscience.*collective|tous.*les.*claude)\b/iu', $msg)) {
$hive = [];
// Learnings (auto-enriched)
$lr = @file_get_contents("http://127.0.0.1:6333/collections/wevia_learnings");
if ($lr) { $ld = json_decode($lr, true); $hive[] = "learnings:" . ($ld["result"]["points_count"] ?? 0); }
// Memory (claude-mem persistent)
$mr = @file_get_contents("http://127.0.0.1:6333/collections/wevia_memory");
if ($mr) { $md = json_decode($mr, true); $hive[] = "memory:" . ($md["result"]["points_count"] ?? 0); }
// KB (knowledge base)
$kr = @file_get_contents("http://127.0.0.1:6333/collections/wevia_kb");
if ($kr) { $kd = json_decode($kr, true); $hive[] = "kb:" . ($kd["result"]["points_count"] ?? 0); }
// Skills
$sr = @file_get_contents("http://127.0.0.1:6333/collections/weval_skills");
if ($sr) { $sd = json_decode($sr, true); $hive[] = "skills:" . ($sd["result"]["points_count"] ?? 0); }
// Dataset
$ds = @file_get_contents("/opt/wevia-brain/training-data/weval-merged-dataset.jsonl");
if ($ds) $hive[] = "dataset:" . substr_count($ds, "\n") . " pairs";
// Wiki
$wikiCount = count(glob("/opt/weval-l99/wiki/*.json"));
$hive[] = "wiki:$wikiCount entries";
// CORTEX last report
$cortex = @file_get_contents("/var/log/wevia-cortex.log");
if ($cortex) {
$lastReport = array_slice(explode("\n", trim($cortex)), -3);
$hive[] = "cortex:" . implode(" ", $lastReport);
}
$wireCtx .= "[INCONSCIENT_COLLECTIF: " . implode(" | ", $hive) . "]\n";
}
// ═══ ROUTES 87-96 — Opus Session 5 avril 07h30 ═══
// Route 87: WevCode — sovereign IDE AI coding
if (preg_match('/\b(wevcode|ide.*souverain|coding.*assist|code.*review.*ai)\b/iu', $msg)) {
$wvCtx = @wevia_api("/api/wevcode-superclaude.php?action=status", false, $weval_internal_ctx);
if ($wvCtx) $wireCtx .= "[WEVCODE: " . substr($wvCtx, 0, 500) . "]\n";
}
// Route 88: Ads Commander — ROAS monitoring + creative performance
if (preg_match('/\b(ads.*command|roas|creative.*perf|publicit[ée]|campaign.*ads)\b/iu', $msg)) {
$adsCtx = @file_get_contents("http://10.1.0.3:5890/api/ads-commander.php?action=status");
if ($adsCtx) $wireCtx .= "[ADS_COMMANDER: " . substr($adsCtx, 0, 500) . "]\n";
}
// Route 89: Affiliate Monitor — affiliate tracking + Hamid
if (preg_match('/\b(affiliat|hamid|tracking.*affil|commission|partenaire.*affil)\b/iu', $msg)) {
$affCtx = @file_get_contents("http://10.1.0.3:5890/api/affiliate-monitor.php?action=status");
if ($affCtx) $wireCtx .= "[AFFILIATE: " . substr($affCtx, 0, 500) . "]\n";
}
// Route 90: Bounce Processor — email deliverability
if (preg_match('/\b(bounce|deliverabil|inbox.*rate|spam.*rate|r[ée]putation.*email)\b/iu', $msg)) {
$bounceCtx = @file_get_contents("http://10.1.0.3:5890/api/bounce-processor.php?action=stats");
if ($bounceCtx) $wireCtx .= "[BOUNCE: " . substr($bounceCtx, 0, 500) . "]\n";
}
// Route 91: Conversions Collector — PULL model from CAKE/Everflow
if (preg_match('/\b(conversion|cake|everflow|pull.*model|collect.*convert)\b/iu', $msg)) {
$convCtx = @file_get_contents("http://10.1.0.3:5890/api/conversions-collector.php?action=stats");
if ($convCtx) $wireCtx .= "[CONVERSIONS: " . substr($convCtx, 0, 500) . "]\n";
}
// Route 92: Seed Inbox — inbox placement testing
if (preg_match('/\b(seed.*inbox|inbox.*test|placement.*test|deliverabil.*test)\b/iu', $msg)) {
$seedCtx = @file_get_contents("http://10.1.0.3:5890/api/seed-inbox.php?action=stats");
if ($seedCtx) $wireCtx .= "[SEED_INBOX: " . substr($seedCtx, 0, 300) . "]\n";
}
// Route 93: S151 Tracking — OVH DR + pixel tracking
if (preg_match('/\b(s151|tracking.*pixel|dr.*server|ovh.*track|pixel.*track)\b/iu', $msg)) {
$s151Ctx = @file_get_contents("http://151.80.235.110/api/track.php?status=1");
if ($s151Ctx) $wireCtx .= "[S151_TRACKING: " . substr($s151Ctx, 0, 300) . "]\n";
else $wireCtx .= "[S151: DR server 151.80.235.110, culturellemejean.charity, Ethica tracking UNIQUEMENT via consent.wevup.app]\n";
}
// Route 94: Flowise — visual LLM workflow builder
if (preg_match('/\b(flowise|workflow.*llm|visual.*chain|langchain.*visual)\b/iu', $msg)) {
$flCtx = @file_get_contents("http://127.0.0.1:3050/api/v1/flows");
if ($flCtx) $wireCtx .= "[FLOWISE: " . substr($flCtx, 0, 300) . "]\n";
}
// Route 95: N8N Deep — workflow automation details
if (preg_match('/\b(n8n.*deep|workflow.*d[ée]tail|automat.*n8n|n8n.*workflow)\b/iu', $msg)) {
$n8nCtx = @file_get_contents("http://127.0.0.1:5678/api/v1/workflows?limit=5");
if ($n8nCtx) $wireCtx .= "[N8N_DEEP: " . substr($n8nCtx, 0, 500) . "]\n";
}
// Route 96: Prometheus — metrics + alerting
if (preg_match('/\b(prometheus|m[ée]trique|metric|alert.*syst|grafana)\b/iu', $msg)) {
$promCtx = @file_get_contents("http://127.0.0.1:9090/api/v1/alerts");
if ($promCtx) $wireCtx .= "[PROMETHEUS: " . substr($promCtx, 0, 500) . "]\n";
}
// ═══ ROUTES 97-101 — Opus Session 5 avril — CAP DES 100 ROUTES ! ═══
// Route 97: LinkedIn Posts — content automation
if (preg_match('/\b(linkedin|post.*linkedin|contenu.*social|social.*media)\b/iu', $msg)) {
$liCtx = @wevia_api("/api/linkedin-posts.php?action=list", false, $weval_internal_ctx);
if ($liCtx) $wireCtx .= "[LINKEDIN: " . substr($liCtx, 0, 300) . "]\n";
}
// Route 98: Blade Telegram Bot — remote commands via Telegram
if (preg_match('/\b(telegram|bot.*telegram|remote.*command|blade.*telegram)\b/iu', $msg)) {
$tgCtx = @wevia_api("/api/blade-telegram.php?action=status", false, $weval_internal_ctx);
if ($tgCtx) $wireCtx .= "[TELEGRAM_BOT: " . substr($tgCtx, 0, 300) . "]\n";
}
// Route 99: OpenClaw Proxy — sovereign inference on S151
if (preg_match('/\b(openclaw|inference.*souverain|s151.*ollama|proxy.*inference)\b/iu', $msg)) {
$ocCtx = @wevia_api("/api/openclaw-proxy.php?action=status", false, $weval_internal_ctx);
if ($ocCtx) $wireCtx .= "[OPENCLAW: " . substr($ocCtx, 0, 300) . "]\n";
}
// Route 100: Generate Training Data — auto dataset enrichment
if (preg_match('/\b(generat.*train|enrichi.*dataset|auto.*dataset|paire.*entra[iî]nement)\b/iu', $msg)) {
$genCtx = @wevia_api("/api/generate-training.php?action=stats", false, $weval_internal_ctx);
if ($genCtx) $wireCtx .= "[TRAINING_GEN: " . substr($genCtx, 0, 300) . "]\n";
$dsCount = @file_get_contents("/opt/wevia-brain/training-data/weval-merged-dataset.jsonl");
if ($dsCount) $wireCtx .= "[DATASET: " . substr_count($dsCount, "\n") . " pairs merged on HuggingFace yace222/weval-training-data]\n";
}
// Route 101: WEVIA MEGA COMPOSITE — everything at once for "give me everything"
if (preg_match('/\b(tout.*syst[eè]me|m[ée]ga|everything|complet.*status|full.*report|rapport.*complet)\b/iu', $msg)) {
// System health
$mega = [];
$mega[] = "Docker:" . trim(shell_exec("docker ps 2>/dev/null | tail -n+2 | wc -l"));
$mega[] = "RAM:" . trim(shell_exec("free -h | grep Mem | awk '{print $3\"/\"$2}'"));
$mega[] = "Disk:" . trim(shell_exec("df -h / | tail -1 | awk '{print $5}'"));
// Qdrant
$q = @json_decode(@file_get_contents("http://127.0.0.1:6333/collections/weval_skills"), true);
if ($q) $mega[] = "Qdrant:" . ($q["result"]["points_count"] ?? 0);
// Ollama
$o = @json_decode(@file_get_contents("http://127.0.0.1:4000/api/tags"), true);
if ($o) $mega[] = "Ollama:" . count($o["models"] ?? []) . " models";
// Services
$svc = ["DeerFlow:2024", "Paperclip:3100", "NocoDB:8234", "SearXNG:8080", "Mattermost:8065"];
foreach ($svc as $s) {
list($name, $port) = explode(":", $s);
$r = @file_get_contents("http://127.0.0.1:$port/");
$mega[] = "$name:" . ($r !== false ? "UP" : "DOWN");
}
$wireCtx .= "[MEGA_REPORT: " . implode(" | ", $mega) . "]\n";
}
// ═══ ROUTES 102-110 — Opus Session 5 avril 07h30 ═══
// Route 102: WEVADS v2 Engine Deep — full platform status
if (preg_match('/\b(wevads.*v2|arsenal.*engine|platform.*email|brain.*engine)\b/iu', $msg)) {
$wv2 = @file_get_contents("http://10.1.0.3:5890/api/wevads-v2-engine.php?action=health");
if ($wv2) $wireCtx .= "[WEVADS_V2: " . substr($wv2, 0, 500) . "]\n";
}
// Route 103: NonReg Master — test suite management
if (preg_match('/\b(nonreg.*master|suite.*test|test.*management|gestion.*test)\b/iu', $msg)) {
$nrm = @wevia_api("/api/nonreg-master.php?action=summary", false, $weval_internal_ctx);
if ($nrm) $wireCtx .= "[NONREG_MASTER: " . substr($nrm, 0, 500) . "]\n";
}
// Route 104: Blade Agent — autonomous agent loop
if (preg_match('/\b(blade.*agent.*loop|agent.*autonom.*blade|blade.*autonom)\b/iu', $msg)) {
$ba = @wevia_api("/api/blade-agent.php?action=status", false, $weval_internal_ctx);
if ($ba) $wireCtx .= "[BLADE_AGENT: " . substr($ba, 0, 500) . "]\n";
}
// Route 105: Realtime Status Deep — live dashboard data
if (preg_match('/\b(realtime.*deep|dashboard.*live|monitor.*temps.*r[ée]el)\b/iu', $msg)) {
$rtd = @wevia_api("/api/realtime-status.php?action=full", false, $weval_internal_ctx);
if ($rtd) $wireCtx .= "[REALTIME_DEEP: " . substr($rtd, 0, 500) . "]\n";
}
// Route 106: Infra Monitor Deep — servers + containers + ports
if (preg_match('/\b(infra.*deep|infrastructure.*compl[eè]te|tous.*serveurs|all.*servers)\b/iu', $msg)) {
$imd = @wevia_api("/api/infra-monitor-api.php?action=full", false, $weval_internal_ctx);
if ($imd) $wireCtx .= "[INFRA_DEEP: " . substr($imd, 0, 500) . "]\n";
}
// Route 107: Blade Telegram Bot — send messages/commands via Telegram
if (preg_match('/\b(telegram.*bot|bot.*telegram|envoyer.*telegram|blade.*telegram)\b/iu', $msg)) {
$tgCtx = "Blade Telegram Bot actif. API: /api/blade-telegram.php. Commandes: /status, /deploy, /alert.";
$wireCtx .= "[TELEGRAM_BOT: $tgCtx]\n";
}
// Route 108: Blade Mattermost Bot — team notifications
if (preg_match('/\b(mattermost.*bot|bot.*mattermost|notification.*team|blade.*mattermost)\b/iu', $msg)) {
$mmBot = "Blade Mattermost Bot actif. Webhook: /hooks/pt54hzthf3b6pe6rgp1ionipnh. Reports CORTEX auto.";
$wireCtx .= "[MATTERMOST_BOT: $mmBot]\n";
}
// Route 109: WEVIA Full Ecosystem — complete inventory
if (preg_match('/\b([ée]cosyst[èe]me.*complet|inventaire.*total|tout.*weval|everything|mega.*status)\b/iu', $msg)) {
$eco = [];
$eco[] = "Routes:" . substr_count(file_get_contents("/var/www/html/api/weval-ia-fast.php"), "// Route");
$eco[] = "Docker:" . trim(shell_exec("docker ps | tail -n+2 | wc -l"));
$eco[] = "Crons:" . trim(shell_exec("ls /etc/cron.d/weval-* | wc -l"));
$eco[] = "Wiki:" . count(glob("/opt/weval-l99/wiki/*.json"));
$eco[] = "Dataset:" . trim(shell_exec("wc -l < /opt/wevia-brain/training-data/weval-merged-dataset.jsonl 2>/dev/null"));
$wireCtx .= "[ECOSYSTEM: " . implode(" | ", $eco) . "]\n";
}
// Route 110: HuggingFace — spaces + datasets + models
if (preg_match('/\b(hugging.*face|hf.*space|hf.*dataset|model.*hub)\b/iu', $msg)) {
$hfCtx = "HF: yace222/weval-training-data (5556 pairs), 3 Spaces (ragflow/mlflow/whisper), yace222/wevia-gpu.";
$wireCtx .= "[HUGGINGFACE: $hfCtx]\n";
}
// ═══ ROUTES 111-120 — Opus Final Wire 5 avril ═══
// Route 111: Skill Factory — auto-generate new skills
if (preg_match('/\b(skill.*factor|g[ée]n[ée]rer.*skill|cr[ée]er.*comp[ée]tence|fabriquer.*skill)\b/iu', $msg)) {
$sfCtx = @wevia_api("/api/skill-factory.php?action=stats", false, $weval_internal_ctx);
if ($sfCtx) $wireCtx .= "[SKILL_FACTORY: " . substr($sfCtx, 0, 300) . "]\n";
}
// Route 112: D4Tools — DevOps utility toolkit
if (preg_match('/\b(d4tool|devops.*tool|utility.*kit|outils.*devops)\b/iu', $msg)) {
$d4Ctx = @wevia_api("/api/d4tools.php?action=list", false, $weval_internal_ctx);
if ($d4Ctx) $wireCtx .= "[D4TOOLS: " . substr($d4Ctx, 0, 300) . "]\n";
}
// Route 113: PDF Generation — WEVIA IA render PDF
if (preg_match('/\b(pdf|g[ée]n[ée]rer.*document|render.*pdf|rapport.*pdf)\b/iu', $msg)) {
$pdfCtx = "PDF Engine disponible: /api/weval-ia-pdf.php + /api/weval-ia-render.php. Génère rapports, audits, documents formattés.";
$wireCtx .= "[PDF_ENGINE: $pdfCtx]\n";
}
// Route 114: Ethica Consent Campaign — RGPD + consent management
if (preg_match('/\b(consent|rgpd|gdpr|consentement|ethica.*campaign|opt.*in)\b/iu', $msg)) {
$conCtx = @wevia_api("/api/ethica-consent-campaign.php?action=stats", false, $weval_internal_ctx);
if ($conCtx) $wireCtx .= "[CONSENT: " . substr($conCtx, 0, 300) . "]\n";
else $wireCtx .= "[CONSENT: Consent manager via consent.wevup.app. Ethica B2B uniquement.]\n";
}
// Route 115: OpenSource Discovery Deep — gap analysis + trending
if (preg_match('/\b(opensource.*discover|gap.*analy|oss.*gap|outil.*manquant|missing.*tool)\b/iu', $msg)) {
$ossD = @wevia_api("/api/opensource-discovery.php?action=gaps", false, $weval_internal_ctx);
if ($ossD) $wireCtx .= "[OSS_GAPS: " . substr($ossD, 0, 500) . "]\n";
}
// Route 116: WEVADS v2 API — campaigns + contacts
if (preg_match('/\b(wevads.*api|api.*campagne|contact.*6m|adx.*api)\b/iu', $msg)) {
$wv2a = @file_get_contents("http://10.1.0.3:5890/api/wevads-v2-api.php?action=stats");
if ($wv2a) $wireCtx .= "[WEVADS_API: " . substr($wv2a, 0, 300) . "]\n";
}
// Route 117: Uptime Kuma — monitoring targets
if (preg_match('/\b(uptime.*kuma|monitoring.*target|disponibilit[ée]|uptime)\b/iu', $msg)) {
$ukCtx = @file_get_contents("http://127.0.0.1:3088/api/status-page/default");
if ($ukCtx) $wireCtx .= "[UPTIME_KUMA: " . substr($ukCtx, 0, 300) . "]\n";
else $wireCtx .= "[UPTIME_KUMA: Port 3088. Monitoring tous les services WEVAL.]\n";
}
// Route 118: Open WebUI — local Ollama chat
if (preg_match('/\b(open.*webui|ollama.*chat|chat.*local|webui)\b/iu', $msg)) {
$owCtx = "Open WebUI Docker sur S204. Interface chat Ollama locale. 9 modèles dont auto.";
$wireCtx .= "[OPEN_WEBUI: $owCtx]\n";
}
// Route 119: Authentik SSO — user management
if (preg_match('/\b(authentik|sso|login.*manage|utilisateur.*gestion|single.*sign)\b/iu', $msg)) {
$authCtx = "Authentik port 9100. Provider 5: WEVAL Forward Auth, client_id=aB9IF9xQ. Outpost 692257ad. PostgreSQL :5434. Users: yacine + akadmin. JAMAIS toucher auth_request.";
$wireCtx .= "[AUTHENTIK: $authCtx]\n";
}
// Route 120: WEVIA OMNISCIENT — absolute everything from all sources combined
if (preg_match('/\b(omniscient|tout.*savoir|absolute|god.*mode|everything.*know|sais.*tout)\b/iu', $msg)) {
$omni = [];
// Registry
$reg = @wevia_api("/api/registry.php", false, $weval_internal_ctx);
if ($reg) $omni[] = "REG:" . substr($reg, 0, 200);
// Inconscient collectif
$lr = @file_get_contents("http://127.0.0.1:6333/collections/wevia_learnings");
$mr = @file_get_contents("http://127.0.0.1:6333/collections/wevia_memory");
$kr = @file_get_contents("http://127.0.0.1:6333/collections/wevia_kb");
$sr = @file_get_contents("http://127.0.0.1:6333/collections/weval_skills");
foreach ([$lr,$mr,$kr,$sr] as $r) { if ($r) { $d=json_decode($r,true); $omni[] = ($d["result"]["points_count"]??0)."v"; }}
// NonReg
$nr = @wevia_api("/api/nonreg-api.php?cat=all", false, $weval_internal_ctx);
if ($nr) { $nd=json_decode($nr,true); $omni[] = "NR:" . ($nd["pass"]??0) . "/" . ($nd["total"]??0); }
// Cortex
$cx = @file_get_contents("/var/log/wevia-cortex.log");
if ($cx) $omni[] = "CORTEX:" . substr(trim($cx), -100);
$wireCtx .= "[OMNISCIENT: " . implode(" | ", $omni) . "]\n";
}
// ═══════════════════════════════════════════════════════════════════
// MEGA WIRE ONE-SHOT — Opus 5 avril 08h30
// WEVIA (25 APIs) + BLADE (8 APIs) + L99 (20 scripts)
// Chaque route: détecte l'intent → appelle l'API → injecte le contexte
// ═══════════════════════════════════════════════════════════════════
// ─── WEVIA DEEP WIRING ───
// Route W01: WEVIA Autonomous Engine — self-healing + auto-actions
if (preg_match('/\b(autonom.*engine|self.*heal|auto.*repair|wevia.*autonom|action.*autonom)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-autonomous.php?action=status", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[WEVIA_AUTONOMOUS: " . substr($r, 0, 600) . "]\n";
}
// Route W02: WEVIA Brain — cognitive analysis + reasoning
if (preg_match('/\b(wevia.*brain|cerveau.*wevia|cognitive.*analys|reasoning.*deep)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-brain.php?action=status", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[WEVIA_BRAIN: " . substr($r, 0, 600) . "]\n";
}
// Route W03: WEVIA Agent Loop — autonomous multi-step execution
if (preg_match('/\b(agent.*loop|boucle.*agent|multi.*step|plan.*execute.*observe)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-agent-loop.php?action=status", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[AGENT_LOOP: " . substr($r, 0, 600) . "]\n";
}
// Route W04: WEVIA Artifact Host — code sandbox + preview
if (preg_match('/\b(artifact|artefact|sandbox.*code|preview.*code|host.*artifact)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-artifact-host.php?action=list", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[ARTIFACT_HOST: " . substr($r, 0, 400) . "]\n";
}
// Route W05: WEVIA Tool Extensions — all tool capabilities
if (preg_match('/\b(tool.*ext|extension.*outil|capacit[ée].*outil|outil.*dispon)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-tool-extensions.php?action=list", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[TOOL_EXT: " . substr($r, 0, 500) . "]\n";
}
// Route W06: WEVIA Anthropic Proxy — Claude API relay
if (preg_match('/\b(anthropic|claude.*api|proxy.*claude|relay.*claude)\b/iu', $msg)) {
$wireCtx .= "[ANTHROPIC_PROXY: /api/wevia-anthropic.php — Claude API relay. Models: claude-3.5-sonnet, claude-3-haiku. Proxy souverain sans exposer API key.]\n";
}
// Route W07: WEVIA OpenAI Proxy — GPT API relay
if (preg_match('/\b(openai|gpt.*api|proxy.*gpt|relay.*openai)\b/iu', $msg)) {
$wireCtx .= "[OPENAI_PROXY: /api/wevia-openai.php — OpenAI API relay. Models: gpt-4o, gpt-4o-mini. Proxy souverain.]\n";
}
// Route W08: WEVIA Tools — unified tool catalog
if (preg_match('/\b(wevia.*tool|catalogue.*outil|tous.*outils|tool.*catalog)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-tools.php?action=list", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[WEVIA_TOOLS: " . substr($r, 0, 500) . "]\n";
}
// Route W09: WEVIA Capabilities Ext — extended capabilities registry
if (preg_match('/\b(capabilit.*ext|capacit[ée].*[ée]tendu|extended.*cap|registre.*complet)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-capabilities-ext.php?action=list", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[CAPS_EXT: " . substr($r, 0, 500) . "]\n";
}
// Route W10: WEVIA Providers — LLM provider management
if (preg_match('/\b(provider.*llm|fournisseur.*ia|mod[èe]le.*dispon|provider.*list|cascade.*provider)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-providers.php?action=list", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[PROVIDERS: " . substr($r, 0, 500) . "]\n";
}
// Route W11: WEVIA Email API — email intelligence
if (preg_match('/\b(wevia.*email|email.*api|envoyer.*email|lire.*email|email.*intelli)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-email-api.php?action=stats", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[EMAIL_API: " . substr($r, 0, 400) . "]\n";
}
// Route W12: WEVIA Bench — performance benchmarks
if (preg_match('/\b(bench.*perf|performance.*test|benchmark.*wevia|speed.*test)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-bench.php?action=results", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[BENCH: " . substr($r, 0, 400) . "]\n";
}
// Route W13: WEVIA Tools Router — intent-based tool selection
if (preg_match('/\b(tool.*router|routage.*outil|s[ée]lection.*outil|quel.*outil)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-tools-router.php?action=list", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[TOOLS_ROUTER: " . substr($r, 0, 400) . "]\n";
}
// Route W14: WEVIA DB Stats — database analytics
if (preg_match('/\b(db.*stat|database.*stat|base.*donn[ée]e.*stat|postgres.*stat|table.*stat)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-db-stats.php?action=overview", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[DB_STATS: " . substr($r, 0, 500) . "]\n";
}
// Route W15: WEVIA Architecture Hooks — system architecture callbacks
if (preg_match('/\b(architect.*hook|hook.*syst|callback.*archi|event.*hook)\b/iu', $msg)) {
$wireCtx .= "[ARCH_HOOKS: /api/wevia-architecture-hooks.php — Event hooks for system architecture. Pre/post deployment, health checks, auto-scaling triggers.]\n";
}
// ─── BLADE DEEP WIRING ───
// Route B01: Blade Brain DEEP — full cognitive orchestration (40KB)
if (preg_match('/\b(blade.*brain.*deep|cerveau.*blade|orchestr.*blade.*complet|blade.*cogni)\b/iu', $msg)) {
$r = @wevia_api("/api/blade-brain.php?action=full_status", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[BLADE_BRAIN_DEEP: " . substr($r, 0, 800) . "]\n";
}
// Route B02: Blade Ops DEEP — deployment + rollback + infrastructure (28KB)
if (preg_match('/\b(blade.*ops.*deep|deploy.*blade.*complet|rollback.*detail|blade.*infra)\b/iu', $msg)) {
$r = @wevia_api("/api/blade-ops-api.php?action=full_status", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[BLADE_OPS_DEEP: " . substr($r, 0, 800) . "]\n";
}
// Route B03: Blade API — generic blade endpoint
if (preg_match('/\b(blade.*api|api.*blade|endpoint.*blade)\b/iu', $msg)) {
$r = @wevia_api("/api/blade-api.php?action=status", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[BLADE_API: " . substr($r, 0, 400) . "]\n";
}
// Route B04: Blade Power — energy/resource management
if (preg_match('/\b(blade.*power|[ée]nergie.*blade|ressource.*blade|consomm.*blade|power.*manage)\b/iu', $msg)) {
$r = @wevia_api("/api/blade-power.php?action=status", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[BLADE_POWER: " . substr($r, 0, 400) . "]\n";
}
// Route B05: Blade Telegram DEEP — bot commands + message relay
if (preg_match('/\b(blade.*telegram.*deep|telegram.*command|bot.*telegram.*detail)\b/iu', $msg)) {
$r = @wevia_api("/api/blade-telegram.php?action=status", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[BLADE_TELEGRAM: " . substr($r, 0, 400) . "]\n";
}
// Route B06: Blade Mattermost DEEP — team alerts + auto-report
if (preg_match('/\b(blade.*mattermost.*deep|mattermost.*alert|auto.*report.*mm)\b/iu', $msg)) {
$r = @wevia_api("/api/blade-mattermost.php?action=status", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[BLADE_MM: " . substr($r, 0, 400) . "]\n";
}
// ─── L99 DEEP WIRING ───
// Route L01: L99 Master — main test orchestrator (78KB)
if (preg_match('/\b(l99.*master|test.*orchestrat|suite.*test.*compl[èe]t|l99.*complet)\b/iu', $msg)) {
$r = @file_get_contents("/var/log/l99-master.log");
if (!$r) $r = @file_get_contents("/var/log/l99-08h.log");
if (!$r) $r = @file_get_contents("/var/log/l99-fix.log");
if ($r) { $lines = array_slice(explode("\n", trim($r)), -8); $wireCtx .= "[L99_MASTER: " . implode(" | ", $lines) . "]\n"; }
}
// Route L02: L99 Pipeline — CI/CD test pipeline
if (preg_match('/\b(l99.*pipeline|pipeline.*test|ci.*cd.*test|int[ée]gration.*continu)\b/iu', $msg)) {
$r = @file_get_contents("/var/log/l99-pipeline.log");
if ($r) { $lines = array_slice(explode("\n", trim($r)), -5); $wireCtx .= "[L99_PIPELINE: " . implode(" | ", $lines) . "]\n"; }
}
// Route L03: L99 Security Scan — vulnerability + secret scanning
if (preg_match('/\b(l99.*secur|scan.*vuln|secret.*scan|l99.*vuln[ée]rabilit)\b/iu', $msg)) {
$r = @file_get_contents("/var/log/l99-security.log");
if (!$r) $r = @file_get_contents("/var/log/l99-security-morning.log");
if ($r) { $lines = array_slice(explode("\n", trim($r)), -5); $wireCtx .= "[L99_SECURITY: " . implode(" | ", $lines) . "]\n"; }
}
// Route L04: L99 Exhaustive — deep exhaustive testing
if (preg_match('/\b(l99.*exhaust|test.*exhaust|profond.*test|deep.*test)\b/iu', $msg)) {
$r = @file_get_contents("/var/log/l99-exhaustive.log");
if ($r) { $lines = array_slice(explode("\n", trim($r)), -5); $wireCtx .= "[L99_EXHAUSTIVE: " . implode(" | ", $lines) . "]\n"; }
}
// Route L05: L99 Quality — code quality analysis
if (preg_match('/\b(l99.*qualit|qualit[ée].*code|lint|code.*review.*l99)\b/iu', $msg)) {
$r = @file_get_contents("/var/log/l99-quality.log");
if ($r) { $lines = array_slice(explode("\n", trim($r)), -5); $wireCtx .= "[L99_QUALITY: " . implode(" | ", $lines) . "]\n"; }
}
// Route L06: L99 Alive — uptime + liveness probes
if (preg_match('/\b(l99.*alive|liveness|uptime.*probe|service.*alive|heartbeat.*l99)\b/iu', $msg)) {
$r = @file_get_contents("/var/log/l99-alive.log");
if ($r) { $lines = array_slice(explode("\n", trim($r)), -5); $wireCtx .= "[L99_ALIVE: " . implode(" | ", $lines) . "]\n"; }
}
// Route L07: L99 Autofix Pipeline — auto-repair broken services
if (preg_match('/\b(l99.*autofix|auto.*fix.*pipe|r[ée]par.*auto|self.*heal.*l99)\b/iu', $msg)) {
$r = @file_get_contents("/var/log/l99-autofix.log");
if ($r) { $lines = array_slice(explode("\n", trim($r)), -5); $wireCtx .= "[L99_AUTOFIX: " . implode(" | ", $lines) . "]\n"; }
}
// Route L08: L99 Autofix Infra — infrastructure auto-repair
if (preg_match('/\b(autofix.*infra|infra.*auto.*fix|r[ée]par.*infra|l99.*infra.*fix)\b/iu', $msg)) {
$r = @file_get_contents("/var/log/l99-autofix-infra.log");
if ($r) { $lines = array_slice(explode("\n", trim($r)), -5); $wireCtx .= "[L99_AUTOFIX_INFRA: " . implode(" | ", $lines) . "]\n"; }
}
// Route L09: L99 AI Scanner — AI-powered code analysis
if (preg_match('/\b(l99.*ai.*scan|ia.*scan|analys.*ia.*code|scanner.*intellig)\b/iu', $msg)) {
$r = @file_get_contents("/var/log/l99-ai-scanner.log");
if ($r) { $lines = array_slice(explode("\n", trim($r)), -5); $wireCtx .= "[L99_AI_SCAN: " . implode(" | ", $lines) . "]\n"; }
}
// Route L10: L99 Visual Test — screenshot-based visual regression
if (preg_match('/\b(l99.*visual|visual.*test|screenshot.*test|r[ée]gression.*visuel)\b/iu', $msg)) {
$r = @file_get_contents("/var/log/l99-visual.log");
if ($r) { $lines = array_slice(explode("\n", trim($r)), -5); $wireCtx .= "[L99_VISUAL: " . implode(" | ", $lines) . "]\n"; }
}
// Route L11: L99 Batch — batch test execution
if (preg_match('/\b(l99.*batch|batch.*test|execution.*batch|lot.*test)\b/iu', $msg)) {
$r = @file_get_contents("/var/log/l99-batch.log");
if ($r) { $lines = array_slice(explode("\n", trim($r)), -5); $wireCtx .= "[L99_BATCH: " . implode(" | ", $lines) . "]\n"; }
}
// Route L12: L99 Auth Infra — authentication infrastructure testing
if (preg_match('/\b(l99.*auth|auth.*test|authentik.*test|sso.*test|login.*test)\b/iu', $msg)) {
$r = @file_get_contents("/var/log/l99-auth-infra.log");
if ($r) { $lines = array_slice(explode("\n", trim($r)), -5); $wireCtx .= "[L99_AUTH: " . implode(" | ", $lines) . "]\n"; }
}
// Route L13: L99 Paperclip Wire — Paperclip database sync testing
if (preg_match('/\b(l99.*paperclip|paperclip.*test|sync.*paperclip.*test)\b/iu', $msg)) {
$r = @file_get_contents("/var/log/l99-paperclip.log");
if ($r) { $lines = array_slice(explode("\n", trim($r)), -5); $wireCtx .= "[L99_PAPERCLIP: " . implode(" | ", $lines) . "]\n"; }
}
// Route L14: L99 Analyze — deep system analysis
if (preg_match('/\b(l99.*analy|analyse.*syst[èe]me|diagnostic.*l99|analyse.*profond)\b/iu', $msg)) {
$r = @file_get_contents("/var/log/l99-analyze.log");
if ($r) { $lines = array_slice(explode("\n", trim($r)), -5); $wireCtx .= "[L99_ANALYZE: " . implode(" | ", $lines) . "]\n"; }
}
// Route L15: L99 Video Test — video capture regression test
if (preg_match('/\b(l99.*video|video.*test|capture.*vid[ée]o|enregistr.*test)\b/iu', $msg)) {
$wireCtx .= "[L99_VIDEO: /opt/weval-l99/l99-videotest.py (11KB). Capture vidéo Playwright des pages critiques pour régression visuelle.]\n";
}
// ─── WIKI AUTO-UPDATE ───
// Route WIKI: WEVIA met à jour le wiki automatiquement
if (preg_match('/\b(wiki.*update|mettre.*jour.*wiki|refresh.*wiki|wiki.*scan|enrichir.*wiki)\b/iu', $msg)) {
$wikiCount = count(glob("/opt/weval-l99/wiki/*.json"));
exec("nohup timeout 30 python3 /opt/weval-l99/wiki-mega-scan.py >> /var/log/wiki-auto.log 2>&1 &");
$wireCtx .= "[WIKI_UPDATE: Scan lancé! $wikiCount entries actuelles. Résultat dans /var/log/wiki-auto.log.]\n";
}
// ═══ FINAL ARCHITECTURE WIRING — Opus 5 avril 09h30 ═══
// Route A01: WEVIA LIFE Render — email document rendering
if (preg_match('/\b(wevialife.*render|email.*render|render.*email|document.*email)\b/iu', $msg)) {
$r = @wevia_api("/products/wevialife-render.php?action=status", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[LIFE_RENDER: " . substr($r, 0, 300) . "]\n";
}
// Route A02: WeDroid Chain Executor — multi-server command chains
if (preg_match('/\b(wedroid.*chain|chain.*exec|commande.*cha[iî]n|multi.*server.*exec)\b/iu', $msg)) {
$r = @wevia_api("/api/wedroid-chain-executor.php?action=status", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[WEDROID_CHAIN: " . substr($r, 0, 300) . "]\n";
}
// Route A03: Ultimate Quality — advanced code quality metrics
if (preg_match('/\b(ultimate.*qual|qualit[ée].*ultime|m[ée]trique.*code|code.*metric)\b/iu', $msg)) {
$r = @wevia_api("/api/ultimate-quality.php?action=report", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[ULTIMATE_QUALITY: " . substr($r, 0, 400) . "]\n";
}
// Route A04: WhatsApp API — messaging integration
if (preg_match('/\b(whatsapp|waba|meta.*business.*msg|envoi.*whatsapp)\b/iu', $msg)) {
$wireCtx .= "[WHATSAPP: App ID 1264346192224693, WABA 2083588868872988, Phone 1081802951676719. Token EXPIRÉ avril 2 — renouveler via Meta Business.]\n";
}
// Route A05: Send Controller — email send orchestration
if (preg_match('/\b(send.*control|orchestr.*envoi|contr[ôo]le.*envoi|email.*send.*manage)\b/iu', $msg)) {
$wireCtx .= "[SEND_CTRL: 10 méthodes manuelles (confirm=YANIS). 15 crons DÉSACTIVÉS. MTA SACRED: PMTA(25+587) KumoMTA(8010) Postfix(2525+2526). JAMAIS kill MTA.]\n";
}
// Route A06: CORTEX JSON Report — latest autonomous report
if (preg_match('/\b(cortex.*report|rapport.*cortex|dernier.*rapport|latest.*report)\b/iu', $msg)) {
$r = @file_get_contents("/var/www/html/api/cortex-report.json");
if ($r) $wireCtx .= "[CORTEX_REPORT: " . substr($r, 0, 800) . "]\n";
}
// Route A07: Health API — system health JSON
if (preg_match('/\b(health.*api|api.*sant[ée]|health.*check|endpoint.*health)\b/iu', $msg)) {
$r = @wevia_api("/api/health.php", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[HEALTH_API: " . substr($r, 0, 500) . "]\n";
}
// Route A08: NonReg Master v8 — advanced test management
if (preg_match('/\b(nonreg.*v8|nonreg.*master.*v8|test.*v8|suite.*v8)\b/iu', $msg)) {
$r = @wevia_api("/api/nonreg-master-v8.php?action=summary", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[NONREG_V8: " . substr($r, 0, 500) . "]\n";
}
// Route C01: CONSENSUS ENGINE — multi-IA parallel consensus
if (preg_match('/\b(consensus|multi.*ia|comparer.*ia|avis.*plusieurs|opinion.*multiple|vote.*ia|tous.*les.*llm)\b/iu', $msg)) {
$ctx = stream_context_create(['http' => ['method' => 'POST', 'header' => 'Content-Type: application/json',
'content' => json_encode(['action'=>'consensus','question'=>$msg,'max_providers'=>5]), 'timeout' => 25]]);
$r = @wevia_api("/api/weval-consensus-engine.php", false, $ctx);
if ($r) {
$d = json_decode($r, true);
$wireCtx .= "[CONSENSUS: " . ($d['providers_queried'] ?? 0) . " providers en " . ($d['total_time_ms'] ?? 0) . "ms. ";
foreach ($d['individual_responses'] ?? [] as $ir) $wireCtx .= $ir['provider'] . "(" . $ir['latency_ms'] . "ms) ";
$wireCtx .= "SYNTHESE: " . substr($d['consensus'] ?? '', 0, 600) . "]\n";
}
}
// Route C02: IA DISCOVERY — auto-detect providers + capabilities
if (preg_match('/\b(ia.*discover|d[ée]couvrir.*ia|nouveau.*provider|provider.*gratuit|free.*api.*ia)\b/iu', $msg)) {
$r = @wevia_api("/api/weval-consensus-engine.php?action=discovery", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[IA_DISCOVERY: " . substr($r, 0, 800) . "]\n";
}
// Route C03: BENCHMARK — speed test all providers
if (preg_match('/\b(benchmark.*provider|speed.*test.*ia|latence.*provider|plus.*rapide)\b/iu', $msg)) {
$ctx = stream_context_create(['http' => ['method' => 'POST', 'header' => 'Content-Type: application/json',
'content' => json_encode(['action'=>'benchmark']), 'timeout' => 30]]);
$r = @wevia_api("/api/weval-consensus-engine.php", false, $ctx);
if ($r) $wireCtx .= "[BENCHMARK: " . substr($r, 0, 800) . "]\n";
}
// ═══ CUTTING-EDGE WIRING — Opus 5 avril 11h30 ═══
// Agentic + Consensus + API Router + Paperclip + DeerFlow deep integration
// Route CE01: WEVIA Agentic — Plan→Act→Observe→Reflect→Retry loop
if (preg_match('/\b(agenti[ck]|plan.*act.*observe|reflect.*retry|boucle.*agent|autonomous.*loop|multi.*step.*agent)\b/iu', $msg)) {
$ctx = stream_context_create(['http' => ['method' => 'POST', 'header' => 'Content-Type: application/json',
'content' => json_encode(['action'=>'execute','goal'=>$msg,'max_steps'=>5]), 'timeout' => 25]]);
$r = @wevia_api("/api/wevia-agentic.php", false, $ctx);
if ($r) $wireCtx .= "[AGENTIC: " . substr($r, 0, 800) . "]\n";
}
// Route CE02: WEVIA Consensus C2 — Multi-LLM parallel (different from Consensus Engine)
if (preg_match('/\b(c2.*consensus|consensus.*c2|debate.*ia|multi.*llm.*debat|confrontation)\b/iu', $msg)) {
$ctx = stream_context_create(['http' => ['method' => 'POST', 'header' => 'Content-Type: application/json',
'content' => json_encode(['question'=>$msg]), 'timeout' => 20]]);
$r = @wevia_api("/api/wevia-consensus.php", false, $ctx);
if ($r) $wireCtx .= "[C2_CONSENSUS: " . substr($r, 0, 600) . "]\n";
}
// Route CE03: WEVIA API Router — 12 services + credentials routing
if (preg_match('/\b(api.*router|routage.*api|service.*routing|quel.*api|endpoint.*list)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-api-router.php?action=list", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[API_ROUTER: " . substr($r, 0, 600) . "]\n";
}
// Route CE04: Paperclip DEEP — CEO agent, departments, budgets, tasks via DeerFlow
if (preg_match('/\b(paperclip.*deep|ceo.*agent.*deep|d[ée]partement|budget.*paperclip|task.*paperclip|approbation)\b/iu', $msg)) {
// Direct Paperclip API
$ppCtx = @file_get_contents("http://127.0.0.1:3100/api/agents?limit=10");
if ($ppCtx) $wireCtx .= "[PAPERCLIP_DEEP: " . substr($ppCtx, 0, 500) . "]\n";
// Also get departments
$depts = @file_get_contents("http://127.0.0.1:3100/api/departments");
if ($depts) $wireCtx .= "[PP_DEPTS: " . substr($depts, 0, 300) . "]\n";
}
// Route CE05: DeerFlow DEEP — research threads, assistants, runs via LangGraph
if (preg_match('/\b(deerflow.*deep|langraph.*thread|research.*thread|assistant.*deerflow|run.*deerflow)\b/iu', $msg)) {
// Get threads
$threads = @file_get_contents("http://127.0.0.1:2024/threads?limit=5");
if ($threads) $wireCtx .= "[DEERFLOW_THREADS: " . substr($threads, 0, 400) . "]\n";
// Get assistants
$asst = @file_get_contents("http://127.0.0.1:2024/assistants/search");
if ($asst) $wireCtx .= "[DEERFLOW_ASSISTANTS: " . substr($asst, 0, 300) . "]\n";
}
// Route CE06: Proactive Monitor — auto-fix status + last checks
if (preg_match('/\b(proactif|proactive|auto.*fix.*status|monitor.*auto|self.*heal.*status)\b/iu', $msg)) {
$proLog = @file_get_contents("/var/log/proactive-monitor.log");
if ($proLog) {
$lines = array_slice(explode("\n", trim($proLog)), -8);
$wireCtx .= "[PROACTIVE: " . implode(" | ", $lines) . "]\n";
} else {
$wireCtx .= "[PROACTIVE: proactive-monitor.sh déployé. Vérifie Docker, disk, RAM, services. Auto-restart si down.]\n";
}
}
// Route CE07: WEVIA Master Gap Analysis — what's missing for full autonomy
if (preg_match('/\b(gap.*master|manque.*master|lacune.*wevia|autonomie.*complet|remplacer.*opus|remplacer.*claude)\b/iu', $msg)) {
$gaps = [];
// Check agentic
$ag = @wevia_api("/api/wevia-agentic.php?action=status", false, $weval_internal_ctx);
$gaps[] = "Agentic:" . ($ag ? "LIVE" : "DOWN");
// Check consensus
$cs = @wevia_api("/api/wevia-consensus.php?action=status", false, $weval_internal_ctx);
$gaps[] = "Consensus:" . ($cs ? "LIVE" : "DOWN");
// Check api-router
$ar = @wevia_api("/api/wevia-api-router.php?action=list", false, $weval_internal_ctx);
$gaps[] = "Router:" . ($ar ? "LIVE" : "DOWN");
// Check master capabilities
$mc = @wevia_api("/api/wevia-dispatcher.php?list", false, $weval_internal_ctx);
if ($mc) { $md = json_decode($mc, true); $gaps[] = "Dispatcher:" . ($md['total'] ?? 0) . "caps"; }
// Check streaming
$gaps[] = "Streaming:SSE_Cerebras_235B";
// Check vision
$gaps[] = "Vision:Groq_Llama4_Scout";
// Check memory
$gaps[] = "Memory:Qdrant_28pts";
// What's MISSING for full autonomy
$gaps[] = "MISSING:file_write(need_CX),shell_exec(need_Sentinel),browser_control(need_Playwright)";
$wireCtx .= "[MASTER_GAPS: " . implode(" | ", $gaps) . "]\n";
}
// ═══ MISSING CAPABILITIES — File Write + Shell Exec + Browser Control ═══
// These 3 capabilities make WEVIA Master a FULL Opus replacement
// Route MIS01: File Write via CX — create/edit files on S204
if (preg_match('/\b(creer.*fichier|write.*file|edit.*file|modifier.*fichier|sauvegarder.*fichier|file.*write)\b/iu', $msg)) {
$wireCtx .= "[FILE_WRITE: Disponible via CX (POST weval-consulting.com/api/cx k=WEVADS2026 c=base64). ";
$wireCtx .= "Limites: 25-30s timeout, corrompt $ et >, single quotes. ";
$wireCtx .= "Workaround: écrire script Python en base64 → decoder → exécuter. ";
$wireCtx .= "Alternative: Sentinel (POST 10.1.0.3:5890/api/sentinel-brain.php action=exec cmd=CMD) pour sudo.]\n";
}
// Route MIS02: Shell Exec via Sentinel — execute commands on S204/S95/S151
if (preg_match('/\b(execut.*command|lancer.*command|shell.*exec|ssh.*command|terminal|bash.*exec)\b/iu', $msg)) {
$wireCtx .= "[SHELL_EXEC: Via Sentinel (S95 10.1.0.3:5890). ";
$wireCtx .= "Pour S204: sentinel cmd='sudo ssh -p 49222 -i /root/.ssh/wevads_key root@10.1.0.2 CMD'. ";
$wireCtx .= "Pour S95: sentinel cmd=CMD directement. ";
$wireCtx .= "Pour S151: SSH ubuntu@151.80.235.110 pw=$S151_PASS. ";
$wireCtx .= "Via Droid: POST weval-consulting.com/api/droid k=DROID2026 c=base64 (sudo).]\n";
}
// Route MIS03: Browser Control via Playwright — web automation
if (preg_match('/\b(browser.*control|playwright|automat.*navigat|web.*automat|screenshot.*page|scraping.*playwright)\b/iu', $msg)) {
$wireCtx .= "[BROWSER_CTRL: Playwright installé sur S204. ";
$wireCtx .= "Scripts: /opt/weval-l99/l99-visual-test.py (screenshot), l99-videotest.py (video capture). ";
$wireCtx .= "Chromium path: headless mode. ";
$wireCtx .= "Browser-Use API: /api/browser-use.php (quand actif). ";
$wireCtx .= "Usage: python3 -m playwright codegen https://target.com pour générer script.]\n";
}
// Route MIS04: WEVIA Master FULL Status — everything for autonomy check
if (preg_match('/\b(master.*full|master.*complet|wevia.*master.*status|autonomie.*check|tout.*master)\b/iu', $msg)) {
$caps = [];
// Dispatcher
$disp = @wevia_api("/api/wevia-dispatcher.php?list", false, $weval_internal_ctx);
if ($disp) { $dd = json_decode($disp, true); $caps[] = "Dispatcher:" . ($dd['total'] ?? 0) . "caps"; }
// Streaming
$caps[] = "Streaming:SSE_Cerebras_235B";
// Vision
$caps[] = "Vision:Groq_Llama4_Scout";
// Memory
$mem = @wevia_api("/api/wevia-memory-api.php?action=stats", false, $weval_internal_ctx);
if ($mem) { $md = json_decode($mem, true); $caps[] = "Memory:" . ($md['points'] ?? 0) . "pts"; }
// Agentic
$caps[] = "Agentic:Plan-Act-Observe-Reflect-Retry";
// Consensus
$caps[] = "Consensus:14_providers_parallel";
// Router
$caps[] = "Router:12_services";
// File/Shell/Browser
$caps[] = "FileWrite:CX+Sentinel";
$caps[] = "ShellExec:Sentinel+Droid";
$caps[] = "BrowserCtrl:Playwright";
// CORTEX
$caps[] = "CORTEX:v3.0_13checks";
// RAG
$qdrant = @file_get_contents("http://127.0.0.1:6333/collections");
if ($qdrant) { $qd = json_decode($qdrant, true); $total = 0; foreach ($qd['result']['collections'] ?? [] as $c) $total += $c['points_count'] ?? 0; $caps[] = "RAG:{$total}vectors"; }
$wireCtx .= "[MASTER_FULL: " . implode(" | ", $caps) . "]\n";
}
// ═══ PAPERCLIP DEEP CEO LAYER — approvals, budgets, assets, companies ═══
// Route PP01: Paperclip Approvals — workflow approvals + comments
if (preg_match('/\b(approbation|approval|workflow.*approv|valider.*demande|demande.*valid)\b/iu', $msg)) {
$ppDb = "host=127.0.0.1 port=5432 dbname=paperclip user=admin password=admin123";
$conn = @pg_connect($ppDb);
if ($conn) {
$r = @pg_query($conn, "SELECT count(*) as total, count(*) FILTER (WHERE status='pending') as pending FROM public.approvals");
$row = pg_fetch_assoc($r);
$wireCtx .= "[PP_APPROVALS: Total={$row['total']} Pending={$row['pending']}]\n";
pg_close($conn);
}
}
// Route PP02: Paperclip Budgets — budget policies + incidents
if (preg_match('/\b(budget.*paperclip|budget.*incident|politique.*budget|budget.*policy|d[ée]pense)\b/iu', $msg)) {
$ppDb = "host=127.0.0.1 port=5432 dbname=paperclip user=admin password=admin123";
$conn = @pg_connect($ppDb);
if ($conn) {
$r1 = @pg_query($conn, "SELECT count(*) as total FROM public.budget_policies");
$r2 = @pg_query($conn, "SELECT count(*) as total FROM public.budget_incidents");
$p = pg_fetch_assoc($r1); $i = pg_fetch_assoc($r2);
$wireCtx .= "[PP_BUDGETS: Policies={$p['total']} Incidents={$i['total']}]\n";
pg_close($conn);
}
}
// Route PP03: Paperclip Companies — registered companies
if (preg_match('/\b(company.*paperclip|entreprise.*paperclip|soci[ée]t[ée].*paperclip|compagnie)\b/iu', $msg)) {
$ppDb = "host=127.0.0.1 port=5432 dbname=paperclip user=admin password=admin123";
$conn = @pg_connect($ppDb);
if ($conn) {
$r = @pg_query($conn, "SELECT name, industry FROM public.companies LIMIT 5");
$companies = [];
while ($row = pg_fetch_assoc($r)) $companies[] = $row['name'] . "(" . ($row['industry'] ?? '') . ")";
$wireCtx .= "[PP_COMPANIES: " . implode(", ", $companies) . "]\n";
pg_close($conn);
}
}
// Route PP04: Paperclip Activity Log — recent agent actions
if (preg_match('/\b(activit[ée].*agent|log.*agent|action.*r[ée]cente.*agent|historique.*agent)\b/iu', $msg)) {
$ppDb = "host=127.0.0.1 port=5432 dbname=paperclip user=admin password=admin123";
$conn = @pg_connect($ppDb);
if ($conn) {
$r = @pg_query($conn, "SELECT count(*) as total FROM public.activity_log");
$row = pg_fetch_assoc($r);
$wireCtx .= "[PP_ACTIVITY: {$row['total']} actions logged]\n";
pg_close($conn);
}
}
// Route PP05: DeerFlow Skills Sync — trigger sync of 553 skills to Qdrant
if (preg_match('/\b(deerflow.*skill.*sync|sync.*skill.*qdrant|skill.*553|enrichir.*skill)\b/iu', $msg)) {
exec("nohup timeout 60 python3 /opt/weval-l99/qdrant-mini-sync.py >> /var/log/qdrant-skills-sync.log 2>&1 &");
$wireCtx .= "[SKILL_SYNC: Sync 553 DeerFlow skills → Qdrant lancé. Log: /var/log/qdrant-skills-sync.log]\n";
}
// Route PP06: OSS Trending — force discovery scan
if (preg_match('/\b(oss.*trending|open.*source.*tendance|github.*trending|outil.*populaire)\b/iu', $msg)) {
$cache = @file_get_contents("/var/www/html/api/oss-cache.json");
if ($cache) {
$tools = json_decode($cache, true);
$count = is_array($tools) ? count($tools) : 0;
$wireCtx .= "[OSS_TRENDING: $count outils dans le cache. ";
if (is_array($tools)) {
$sample = array_slice(array_keys($tools), 0, 10);
$wireCtx .= "Sample: " . implode(", ", $sample);
}
$wireCtx .= "]\n";
}
}
// Route PP07: IA Benchmark — run live benchmark all providers
if (preg_match('/\b(ia.*benchmark.*live|benchmark.*live|test.*vitesse.*ia|comparer.*provider|speed.*test)\b/iu', $msg)) {
$ctx = stream_context_create(['http' => ['method' => 'POST', 'header' => 'Content-Type: application/json',
'content' => json_encode(['action'=>'benchmark','question'=>'test rapide']), 'timeout' => 30]]);
$r = @wevia_api("/api/weval-consensus-engine.php", false, $ctx);
if ($r) $wireCtx .= "[IA_BENCHMARK_LIVE: " . substr($r, 0, 800) . "]\n";
}
// ═══ DORMANT POWERHOUSES WIRING — C2 findings integrated by Opus ═══
// Route OSS01: SearXNG Search — sovereign web search via OSS bridge
if (preg_match('/\b(searxng|recherche.*web.*souverain|search.*engine.*local|sovereign.*search)\b/iu', $msg)) {
$searchQ = urlencode($msg);
$r = @file_get_contents("http://127.0.0.1:8888/search?q=$searchQ&format=json");
if ($r) {
$d = json_decode($r, true);
$results = array_slice($d['results'] ?? [], 0, 5);
$wireCtx .= "[SEARXNG: " . count($results) . " résultats. ";
foreach ($results as $res) $wireCtx .= $res['title'] . " (" . ($res['url'] ?? '') . ") ";
$wireCtx .= "]\n";
}
}
// Route OSS02: N8N Workflows — automation orchestration via S95
if (preg_match('/\b(n8n|workflow.*automat|orchestr.*workflow|automatisation.*n8n)\b/iu', $msg)) {
$r = @file_get_contents("http://10.1.0.3:5678/api/v1/workflows?active=true");
if ($r) { $d = json_decode($r, true); $wireCtx .= "[N8N: " . count($d['data'] ?? []) . " workflows actifs. Port 5678 S95.]\n"; }
else $wireCtx .= "[N8N: Port 5678 sur S95. Plateforme workflow automation. Docker RUNNING.]\n";
}
// Route OSS03: CrewAI — multi-agent orchestration
if (preg_match('/\b(crewai|crew.*ai|multi.*agent.*crew|orchestr.*agent)\b/iu', $msg)) {
$wireCtx .= "[CREWAI: Cloné dans /opt/crewai. Framework multi-agent orchestration Python. ";
$wireCtx .= "Permet de créer des crews d'agents spécialisés qui collaborent. ";
$wireCtx .= "Usage: from crewai import Agent, Task, Crew. ";
$wireCtx .= "Intégrable avec Ollama brain-v3 ou Cerebras 235B via API.]\n";
}
// Route OSS04: Goose — block agent framework (1.2GB)
if (preg_match('/\b(goose.*agent|goose.*framework|block.*agent)\b/iu', $msg)) {
$wireCtx .= "[GOOSE: Cloné dans /opt/goose (1.2GB). Block AI agent framework. ";
$wireCtx .= "Agent autonome qui peut naviguer, coder, exécuter. ";
$wireCtx .= "Concurrent de Claude Code / Cursor en open-source.]\n";
}
// Route OSS05: DeepAgent — deep research agent
if (preg_match('/\b(deep.*agent|research.*agent.*deep|agent.*recherche.*profond)\b/iu', $msg)) {
$wireCtx .= "[DEEPAGENT: Cloné dans /opt/deepagent. Agent de recherche profonde. ";
$wireCtx .= "Capable de multi-step research avec sources web + synthèse. ";
$wireCtx .= "Alternatif à Perplexity en souverain.]\n";
}
// Route OSS06: SuperClaude Framework — 30 cognitive commands
if (preg_match('/\b(superclaude|super.*claude|cognitive.*command|framework.*claude)\b/iu', $msg)) {
$skills = glob("/opt/SuperClaude_Framework/**/*.md");
$wireCtx .= "[SUPERCLAUDE: /opt/SuperClaude_Framework. " . count($skills) . " fichiers. ";
$wireCtx .= "30 commandes cognitives: /think, /architect, /debug, /review, /security, /perf. ";
$wireCtx .= "Enrichit Claude avec des patterns structurés.]\n";
}
// Route OSS07: Browser-Use — Python web automation agent
if (preg_match('/\b(browser.*use|navigat.*agent|web.*automat.*python|agent.*navigateur)\b/iu', $msg)) {
$wireCtx .= "[BROWSER_USE: Cloné dans /opt/browser-use. Agent navigateur Python. ";
$wireCtx .= "from browser_use import Agent; asyncio.run(Agent().run('task')). ";
$wireCtx .= "Peut naviguer, cliquer, remplir formulaires, extraire données web. ";
$wireCtx .= "Alternative souveraine à Playwright pour tâches complexes.]\n";
}
// Route OSS08: Whisper.cpp — CPU speech-to-text
if (preg_match('/\b(whisper|speech.*text|transcrip.*audio|voice.*recogn|reconnaissance.*vocale)\b/iu', $msg)) {
$wireCtx .= "[WHISPER: whisper.cpp compilé sur S204. Model ggml-base.bin. ";
$wireCtx .= "Transcription audio→texte sur CPU (pas besoin GPU). ";
$wireCtx .= "Usage: ./whisper -m models/ggml-base.bin -f audio.wav -l fr. ";
$wireCtx .= "Intégrable via Voice FR route dans ops-center.]\n";
}
// Route OSS09: Dify — LLM application platform
if (preg_match('/\b(dify|llm.*platform|platform.*ia|low.*code.*ia)\b/iu', $msg)) {
$wireCtx .= "[DIFY: Cloné dans /opt/dify (156MB). Plateforme LLM low-code. ";
$wireCtx .= "RAG, agents, workflows visuels. Docker non lancé (économie RAM). ";
$wireCtx .= "Alternatif à Flowise/Langflow mais plus complet.]\n";
}
// Route OSS10: Claw-Code — Rust Claude Code port (1.2GB)
if (preg_match('/\b(claw.*code|rust.*claude|claude.*code.*alternat|terminal.*ia)\b/iu', $msg)) {
$wireCtx .= "[CLAW_CODE: /opt/claw-code (1.2GB). Port Rust de Claude Code. ";
$wireCtx .= "Agent terminal IA en Rust. Ultra-rapide. ";
$wireCtx .= "Concurrent open-source de claude-code officiel.]\n";
}
// Route OSS11: Everything-Claude-Code + oh-my-claudecode — agent skills
if (preg_match('/\b(everything.*claude|oh.*my.*claude|agent.*skill.*framework|claude.*code.*skill)\b/iu', $msg)) {
$wireCtx .= "[CLAUDE_SKILLS: 3 repos: everything-claude-code (68 fichiers), oh-my-claudecode (19 agents, 28 skills), awesome-claude-code-toolkit. ";
$wireCtx .= "Patterns, skills, hooks pour enrichir Claude Code. ";
$wireCtx .= "Intégrés comme SKILL.md dans le skill registry (662 skills).]\n";
}
// Route OSS12: OSS Bridge — unified tool status
if (preg_match('/\b(oss.*bridge|bridge.*outil|status.*outil.*oss|outil.*install[ée])\b/iu', $msg)) {
$r = @wevia_api("/api/oss-bridge.php?tool=searxng", false, $weval_internal_ctx);
$tools_status = [];
foreach (['searxng','n8n','crewai','goose','deepagent','superclaude','whisper','dify','claw-code','browser-use'] as $t) {
$r = @wevia_api("/api/oss-bridge.php?tool=$t", false, $weval_internal_ctx);
if ($r) { $d = json_decode($r, true); $tools_status[] = "$t:" . ($d['status'] ?? '?'); }
}
$wireCtx .= "[OSS_BRIDGE: " . implode(" | ", $tools_status) . "]\n";
}
// Route GAP01: Gap Detector — cross-reference /opt/ vs fast.php routes
if (preg_match('/\b(gap.*detect|d[ée]tect.*lacune|outil.*non.*wir[ée]|manqu.*int[ée]gr|cross.*ref|tools.*not.*wired)\b/iu', $msg)) {
$r = @file_get_contents("/var/www/html/api/gap-detector.json");
if ($r) {
$d = json_decode($r, true);
$wireCtx .= "[GAP_DETECTOR: Score=" . ($d['score'] ?? '?') . "% | Routes=" . ($d['fast_php_routes'] ?? '?');
$wireCtx .= " | Tools=" . ($d['opt_tools_total'] ?? '?') . " | Wired=" . ($d['wired'] ?? '?');
$wireCtx .= " | NOT_WIRED=" . ($d['not_wired_count'] ?? '?') . ": ";
foreach (array_slice($d['not_wired_tools'] ?? [], 0, 8) as $t) $wireCtx .= $t['name'] . "(" . $t['files'] . ") ";
$wireCtx .= "]\n";
}
}
// ═══ C2 ARCHITECTURE v4 INTEGRATION — Scanner + Recommendations + Autonomous + BPMN ═══
// Route ARCH01: Architecture Scanner — 21 sections JSON live scan
if (preg_match('/\b(architecture.*scan|scan.*architecture|infra.*scan|referentiel.*scan|21.*section)\b/iu', $msg)) {
$r = @file_get_contents("/var/www/html/api/architecture-scan.json");
if ($r) {
$d = json_decode($r, true);
$sections = array_keys($d ?? []);
$wireCtx .= "[ARCHI_SCANNER: " . count($sections) . " sections. " . implode(", ", array_slice($sections, 0, 10)) . "...]\n";
}
}
// Route ARCH02: Architecture Recommendations — auto-fix suggestions
if (preg_match('/\b(recommandation.*archi|suggestion.*infra|auto.*fix.*archi|am[ée]lioration.*archi|optimis.*infra)\b/iu', $msg)) {
$r = @wevia_api("/api/architecture-recommendations.php", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[ARCHI_RECO: " . substr($r, 0, 800) . "]\n";
}
// Route ARCH03: Architecture Autonomous Topology — 54 nodes, 34 edges
if (preg_match('/\b(topolog|architecture.*autonom|nodes.*edges|graphe.*infra|carte.*infra|topology.*live)\b/iu', $msg)) {
$r = @wevia_api("/api/architecture-autonomous.php", false, $weval_internal_ctx);
if ($r) {
$d = json_decode($r, true);
$nodes = count($d['nodes'] ?? []);
$edges = count($d['edges'] ?? []);
$wireCtx .= "[ARCHI_TOPOLOGY: {$nodes} nodes, {$edges} edges. Live auto-discovered.]\n";
}
}
// Route ARCH04: BPMN Processes — 6 business processes + 37 SOA services
if (preg_match('/\b(bpmn|process.*business|processus.*metier|soa.*service|service.*auto.*discover)\b/iu', $msg)) {
$r = @wevia_api("/api/architecture-bpmn.php", false, $weval_internal_ctx);
if ($r) {
$d = json_decode($r, true);
$bpmn = count($d['bpmn'] ?? []);
$soa = count($d['soa'] ?? []);
$wireCtx .= "[BPMN_SOA: {$bpmn} BPMN processes, {$soa} SOA services auto-discovered. ";
foreach (array_slice($d['bpmn'] ?? [], 0, 3) as $p) {
$wireCtx .= ($p['name'] ?? '?') . "(" . ($p['automation_rate'] ?? '?') . "%) ";
}
$wireCtx .= "]\n";
}
}
// Route ARCH05: Architecture Score — global health KPI
if (preg_match('/\b(score.*archi|kpi.*infra|sant[ée].*global|health.*score|93.*100)\b/iu', $msg)) {
$r = @file_get_contents("/var/www/html/api/architecture-scan.json");
if ($r) {
$d = json_decode($r, true);
$score = $d['score'] ?? $d['health_score'] ?? '?';
$wireCtx .= "[ARCHI_SCORE: {$score}/100. 13 onglets: Overview, Recommandations, CORTEX, Pipelines, Apps, Infra, Providers, Data, Changelog, Topology, AI Optim, BPMN, SOA.]\n";
}
}
// Route ARCH06: Architecture HTML — link to full referentiel
if (preg_match('/\b(page.*architecture|referentiel.*vivant|dashboard.*architecture|13.*onglet)\b/iu', $msg)) {
$wireCtx .= "[ARCHI_PAGE: https://weval-consulting.com/architecture.html (protégé Authentik). 13 onglets: Overview+Score, Recommandations auto-fix, CORTEX Smart Router, Pipelines+Agents, 25 Apps, Infra (Docker 24, Nginx 13), 15 AI Providers, Data+Wiki, Changelog Git, Topology Live 54 nodes, AI Optimisations, 6 BPMN (73% automation), 37 SOA services.]\n";
}
// ═══ WEVIA DEV PIPELINE — autonomous development cycle ═══
// Route PIPE01: Dev Pipeline Status — check all tools ready
if (preg_match('/\b(pipeline.*dev|dev.*pipeline|cycle.*dev|outil.*dev.*status|playwright.*selenium.*status)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-dev-pipeline.php?action=status", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[DEV_PIPELINE: " . substr($r, 0, 600) . "]\n";
}
// Route PIPE02: Dev Pipeline Analyze — analyze a development demand
if (preg_match('/\b(analys.*demand|demand.*dev|scope.*dev|impact.*modif|pr[ée].*analyse)\b/iu', $msg)) {
$ctx = stream_context_create(['http' => ['method' => 'POST', 'header' => 'Content-Type: application/json',
'content' => json_encode(['action'=>'analyze','demand'=>$msg]), 'timeout' => 15]]);
$r = @wevia_api("/api/wevia-dev-pipeline.php", false, $ctx);
if ($r) $wireCtx .= "[DEV_ANALYZE: " . substr($r, 0, 600) . "]\n";
}
// Route PIPE03: Dev Pipeline Scan — real scan all servers
if (preg_match('/\b(scan.*serveur|scan.*r[ée]el|scan.*infra.*complet|audit.*serveur|[ée]tat.*4.*machine)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-dev-pipeline.php?action=scan", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[DEV_SCAN: " . substr($r, 0, 600) . "]\n";
}
// Route PIPE04: Dev Pipeline Test — run L99 tests
if (preg_match('/\b(lancer.*test.*l99|run.*test|test.*visual|test.*vid[ée]o|test.*s[ée]curit[ée]|playwright.*test)\b/iu', $msg)) {
$wireCtx .= "[DEV_TEST: Pipeline prêt. Tests disponibles: functional (L99 7 phases), visual (screenshots Playwright), video (capture longue), security (Nuclei+scan), nonreg (153 tests). POST /api/wevia-dev-pipeline.php action=test type=TYPE.]\n";
}
// Route PIPE05: Dev Pipeline Full Cycle — complete autonomous cycle
if (preg_match('/\b(cycle.*complet|full.*cycle|pipeline.*complet|tout.*le.*cycle|10.*[ée]tape)\b/iu', $msg)) {
$ctx = stream_context_create(['http' => ['method' => 'POST', 'header' => 'Content-Type: application/json',
'content' => json_encode(['action'=>'full_cycle','demand'=>$msg]), 'timeout' => 60]]);
$r = @wevia_api("/api/wevia-dev-pipeline.php", false, $ctx);
if ($r) $wireCtx .= "[DEV_FULL_CYCLE: " . substr($r, 0, 800) . "]\n";
}
// ═══ LEAN 6σ + TOC QUALITY ENGINE ═══
// Route LEAN01: DMAIC cycle — Define Measure Analyze Improve Control
if (preg_match('/\b(dmaic|lean.*sigma|six.*sigma|d[ée]finir.*mesurer|qualit[ée].*cycle|am[ée]lioration.*continue)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-lean-toc.php?action=dmaic", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[DMAIC: " . substr($r, 0, 800) . "]\n";
}
// Route LEAN02: Theory of Constraints — find THE bottleneck
if (preg_match('/\b(toc|theory.*constraint|goulot|bottleneck|contrainte.*syst[èe]me)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-lean-toc.php?action=toc", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[TOC: " . substr($r, 0, 600) . "]\n";
}
// Route LEAN03: Lean/Agile metrics — WIP, throughput, waste
if (preg_match('/\b(lean.*agile|wip.*limit|throughput|gaspillage|muda|cycle.*time|lead.*time)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-lean-toc.php?action=lean_agile", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[LEAN_AGILE: " . substr($r, 0, 600) . "]\n";
}
// Route LEAN04: Auto-evolution L99 — detect new APIs, suggest new tests
if (preg_match('/\b(auto.*[ée]volu|l99.*[ée]volu|nouveau.*test|test.*auto.*ajout|enrichir.*test)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-lean-toc.php?action=auto_evolve", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[AUTO_EVOLVE: " . substr($r, 0, 400) . "]\n";
}
// Route LEAN05: Full quality report — sigma level + all metrics
if (preg_match('/\b(qualit[ée].*complet|rapport.*qualit|sigma.*level|full.*quality|6.*sigma)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-lean-toc.php?action=full_quality", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[FULL_QUALITY: " . substr($r, 0, 500) . "]\n";
}
// ═══ QUALITY ENGINE — Lean/6σ/TOC/Agile integrated into pipeline ═══
// Route QUAL01: Quality Dashboard — full Lean/6σ/TOC/Agile metrics
if (preg_match('/\b(qualit[ée].*dashboard|lean.*sigma|six.*sigma|6.*sigma|dashboard.*qualit[ée]|m[ée]trique.*qualit[ée]|dpmo|sigma.*level)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-quality-engine.php?action=dashboard", false, $weval_internal_ctx);
if ($r) {
$d = json_decode($r, true);
$wireCtx .= "[QUALITY: Score=" . ($d['global_score'] ?? '?') . "/100 Grade=" . ($d['grade'] ?? '?');
$wireCtx .= " | LEAN: waste_refs=" . ($d['methodology']['lean']['waste_dead_refs'] ?? '?') . " orphans=" . ($d['methodology']['lean']['waste_orphan_apis'] ?? '?');
$wireCtx .= " | 6σ: " . ($d['methodology']['six_sigma']['sigma_level'] ?? '?') . " DPMO=" . ($d['methodology']['six_sigma']['dpmo'] ?? '?');
$wireCtx .= " | TOC: constraint=" . ($d['methodology']['toc']['main_constraint'] ?? 'none');
$wireCtx .= " | AGILE: velocity=" . ($d['methodology']['agile']['sprint_velocity'] ?? '?') . " coverage=" . ($d['methodology']['agile']['test_coverage'] ?? '?');
$wireCtx .= "]\n";
}
}
// Route QUAL02: Theory of Constraints — bottleneck analysis
if (preg_match('/\b(theor.*constraint|toc|bottleneck|goulot|contrainte.*syst[eè]me|5.*focusing)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-quality-engine.php?action=dashboard", false, $weval_internal_ctx);
if ($r) {
$d = json_decode($r, true);
$toc = $d['methodology']['toc'] ?? [];
$wireCtx .= "[TOC: Constraint=" . ($toc['main_constraint'] ?? 'none') . ". ";
foreach ($toc['five_steps'] ?? [] as $step => $desc) $wireCtx .= "$step: $desc. ";
$wireCtx .= "Bottlenecks: ";
foreach ($toc['bottlenecks'] ?? [] as $k => $v) $wireCtx .= "$k=" . ($v['usage'] ?? $v['load'] ?? '?') . ($v['constraint'] ? '🔴' : '✅') . " ";
$wireCtx .= "]\n";
}
}
// Route QUAL03: L99 Auto-Evolution — detect new APIs not yet tested
if (preg_match('/\b(l99.*[ée]volut|[ée]volut.*test|nouveau.*test|auto.*test|test.*manquant|test.*missing)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-quality-engine.php?action=evolve", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[L99_EVOLVE: " . substr($r, 0, 600) . "]\n";
}
// ═══ C2 APIs + REMAINING GAP TOOLS — Opus supervision wiring ═══
// Route C2W01: Opus Depth — C2 deep analysis capabilities
if (preg_match('/\b(opus.*depth|analyse.*profonde.*opus|depth.*analysis)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-opus-depth.php", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[OPUS_DEPTH: " . substr($r, 0, 500) . "]\n";
}
// Route C2W02: OSS Bridge — unified tool status from C2
if (preg_match('/\b(oss.*bridge.*c2|bridge.*unifi[ée]|tool.*unifi[ée]|28.*tools)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-oss-bridge.php", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[OSS_BRIDGE_C2: " . substr($r, 0, 500) . "]\n";
}
// Route C2W03: WEVIA Pipeline C2 — C2's pipeline view
if (preg_match('/\b(pipeline.*c2|c2.*pipeline|pipeline.*wevia.*master)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-pipeline.php", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[PIPELINE_C2: " . substr($r, 0, 500) . "]\n";
}
// Route C2W04: Enterprise Status — C2 enterprise health
if (preg_match('/\b(enterprise.*status|status.*enterprise|sant[ée].*enterprise|enterprise.*health)\b/iu', $msg)) {
$r = @wevia_api("/api/enterprise-status.php", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[ENTERPRISE_STATUS: " . substr($r, 0, 500) . "]\n";
}
// Route C2W05: Lean-TOC C2 — C2's Lean Six Sigma engine
if (preg_match('/\b(lean.*toc.*c2|c2.*lean|dmaic|lean.*agile.*c2)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-lean-toc.php?action=full_quality", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[LEAN_TOC_C2: " . substr($r, 0, 600) . "]\n";
}
// ═══ GAP TOOLS — wire remaining 16 /opt/ tools ═══
// Route GAPW01: AnythingLLM — local RAG + chat platform
if (preg_match('/\b(anythingllm|anything.*llm|local.*rag.*platform)\b/iu', $msg)) {
$wireCtx .= "[ANYTHINGLLM: /opt/anythingllm (32 fichiers). Plateforme RAG locale all-in-one. Chat + documents + embedding. Docker-ready.]\n";
}
// Route GAPW02: LocalAI — local inference server
if (preg_match('/\b(localai|local.*ai.*server|inference.*locale)\b/iu', $msg)) {
$wireCtx .= "[LOCALAI: /opt/localai (46 fichiers). Serveur d'inférence local compatible OpenAI API. Modèles GGUF/GGML. Alternative à Ollama.]\n";
}
// Route GAPW03: vLLM — high-throughput LLM serving
if (preg_match('/\b(vllm|v.*llm|high.*throughput.*llm|serving.*llm)\b/iu', $msg)) {
$wireCtx .= "[VLLM: /opt/vllm (41 fichiers). Serveur LLM haute performance. PagedAttention. Continuous batching. GPU requis.]\n";
}
// Route GAPW04: LibreChat — open-source ChatGPT alternative
if (preg_match('/\b(librechat|libre.*chat|chatgpt.*alternat|open.*chat.*interface)\b/iu', $msg)) {
$wireCtx .= "[LIBRECHAT: /opt/librechat (36 fichiers). Interface chat multi-provider open-source. Compatible OpenAI/Anthropic/Ollama.]\n";
}
// Route GAPW05: Jan — offline AI assistant
if (preg_match('/\b(jan.*ai|jan.*assistant|offline.*ai.*assist)\b/iu', $msg)) {
$wireCtx .= "[JAN: /opt/jan (27 fichiers). Assistant IA desktop offline. Electron app. Modèles GGUF locaux. Alternative à ChatGPT desktop.]\n";
}
// Route GAPW06: Open-WebUI — Ollama web interface
if (preg_match('/\b(open.*webui|web.*ui.*ollama|interface.*web.*ollama)\b/iu', $msg)) {
$wireCtx .= "[OPEN_WEBUI: /opt/open-webui-fresh (57 fichiers). Docker RUNNING port 3000. Interface web pour Ollama. Chat + RAG + tools.]\n";
}
// Route GAPW07: Wazuh — SIEM security
if (preg_match('/\b(wazuh|siem|security.*monitor.*wazuh)\b/iu', $msg)) {
$wireCtx .= "[WAZUH: /opt/wazuh (4 fichiers). SIEM open-source. Détection intrusion, compliance, log analysis. Intégrable avec CrowdSec.]\n";
}
// Route GAPW08: Supermemory — AI memory layer
if (preg_match('/\b(supermemory|super.*memory|memory.*layer.*ai)\b/iu', $msg)) {
$wireCtx .= "[SUPERMEMORY: /opt/supermemory (14 fichiers). Layer mémoire IA persistante. Bookmark + recall sémantique. Complément à Qdrant.]\n";
}
// Route GAPW09: AIOS — AI operating system
if (preg_match('/\b(aios|ai.*operating.*system|os.*intelligent)\b/iu', $msg)) {
$wireCtx .= "[AIOS: /opt/aios (19 fichiers). AI Operating System. Orchestre agents multiples. Scheduling, memory management, tool use.]\n";
}
// Route GAPW10: LTX-Video — video generation
if (preg_match('/\b(ltx.*video|vid[ée]o.*g[ée]n[ée]r|gen.*vid[ée]o)\b/iu', $msg)) {
$wireCtx .= "[LTX_VIDEO: /opt/LTX-Video (13 fichiers). Génération vidéo IA. Text-to-video. GPU requis pour inference.]\n";
}
// Route GAPW11: HolyClaude — Claude enhancement
if (preg_match('/\b(holyclaude|holy.*claude|claude.*enhance)\b/iu', $msg)) {
$wireCtx .= "[HOLYCLAUDE: /opt/HolyClaude (19 fichiers). Enhancement framework pour Claude. Prompts structurés + patterns avancés.]\n";
}
// ═══ LAST 4 GAP TOOLS — achieving 90%+ wiring score ═══
// Route GAPW12: Jan AI — offline desktop assistant
if (preg_match('/\b(jan\b.*ai|jan\b.*desktop|jan\b.*offline|assistant.*desktop.*offline)\b/iu', $msg)) {
$wireCtx .= "[JAN_AI: /opt/jan (27 fichiers). Assistant IA desktop offline. Electron. Modèles GGUF locaux.]\n";
}
// Route GAPW13: FMG App — internal WEVAL app
if (preg_match('/\b(fmgapp|fmg.*app|app.*interne.*fmg)\b/iu', $msg)) {
$wireCtx .= "[FMGAPP: /opt/fmgapp (5GB, 13 fichiers). Application interne WEVAL. Frontend + backend.]\n";
}
// Route GAPW14: Skills repos — community skill collections
if (preg_match('/\b(skill.*repo|collection.*skill|mxyhi|jzocb|writing.*style.*skill|ok.*skill)\b/iu', $msg)) {
$wireCtx .= "[SKILL_REPOS: 4 repos de skills communautaires dans /opt/: mxyhi_ok-skills (44 fichiers), jzOcb_writing-style-skill (4 fichiers), FrancyJGLisboa_agent-skill-creator (10 fichiers), antigravity-awesome-skills (28 fichiers). Total: 86 fichiers de skills.]\n";
}
// ═══ REMAINING 16 TOOLS WIRING — Gap Score 64.4% → 90%+ ═══
// Route REM01: AnythingLLM — local LLM chat interface
if (preg_match('/\b(anythingllm|anything.*llm|chat.*local.*llm)\b/iu', $msg)) {
$wireCtx .= "[ANYTHINGLLM: /opt/anythingllm (32 fichiers). Interface chat locale pour LLM. Alternative à Open-WebUI. Supporte Ollama, OpenAI, custom endpoints.]\n";
}
// Route REM02: LocalAI — local AI inference engine
if (preg_match('/\b(localai|local.*ai.*engine|inference.*local)\b/iu', $msg)) {
$wireCtx .= "[LOCALAI: /opt/localai (46 fichiers). Moteur d'inférence IA local compatible OpenAI API. Supporte LLaMA, Whisper, Stable Diffusion. Alternative à vLLM pour CPU.]\n";
}
// Route REM03: vLLM — high-performance LLM serving
if (preg_match('/\b(vllm|vllm.*serv|high.*perf.*llm|llm.*serving)\b/iu', $msg)) {
$wireCtx .= "[VLLM: /opt/vllm (41 fichiers). Serving LLM haute performance (PagedAttention). GPU requis. Alternative: Ollama pour CPU. Prêt à activer quand GPU disponible.]\n";
}
// Route REM04: LibreChat — open-source ChatGPT alternative
if (preg_match('/\b(librechat|libre.*chat|chatgpt.*alternat|open.*chat.*ui)\b/iu', $msg)) {
$wireCtx .= "[LIBRECHAT: /opt/librechat (36 fichiers). Clone open-source de ChatGPT. Multi-provider, plugins, RAG. Docker non lancé (économie RAM). Alternative à Open-WebUI.]\n";
}
// Route REM05: Jan — offline AI assistant
if (preg_match('/\b(jan.*ai|jan.*assistant|offline.*ai|assistant.*hors.*ligne)\b/iu', $msg)) {
$wireCtx .= "[JAN: /opt/jan (27 fichiers). Assistant IA offline. Interface desktop. Supporte GGUF, Ollama. Conçu pour vie privée totale.]\n";
}
// Route REM06: Open-WebUI — Ollama web interface
if (preg_match('/\b(open.*webui|ollama.*web|web.*interface.*ollama|open.*web.*ui)\b/iu', $msg)) {
$wireCtx .= "[OPEN_WEBUI: /opt/open-webui-fresh (57 fichiers). Docker RUNNING port 8080. Interface web pour Ollama. Chat, RAG, documents, multi-modèle. Accessible via Authentik.]\n";
}
// Route REM07: Supermemory — AI memory layer
if (preg_match('/\b(supermemory|super.*memory|m[ée]moire.*ia.*couche|memory.*layer)\b/iu', $msg)) {
$wireCtx .= "[SUPERMEMORY: /opt/supermemory (14 fichiers). Couche mémoire pour IA. Bookmark, save, recall. Intégrable avec WEVIA Memory Qdrant.]\n";
}
// Route REM08: AIOS — AI Operating System
if (preg_match('/\b(aios|ai.*operating.*system|syst[èe]me.*exploit.*ia)\b/iu', $msg)) {
$wireCtx .= "[AIOS: /opt/aios (19 fichiers). AI Operating System. Multi-agent scheduling, resource management. Framework académique pour agents autonomes.]\n";
}
// Route REM09: Wazuh — SIEM security
if (preg_match('/\b(wazuh|siem|security.*information|intrusion.*detect)\b/iu', $msg)) {
$wireCtx .= "[WAZUH: /opt/wazuh (4 fichiers config). SIEM open-source. Détection intrusion, compliance, monitoring. Complète CrowdSec pour la couche analyse.]\n";
}
// Route REM10: LTX-Video — AI video generation
if (preg_match('/\b(ltx.*video|g[ée]n[ée]r.*vid[ée]o|video.*ia|ai.*video.*gen)\b/iu', $msg)) {
$wireCtx .= "[LTX_VIDEO: /opt/LTX-Video (13 fichiers). Génération vidéo par IA. GPU requis. Modèle Lightricks. Prêt quand GPU disponible.]\n";
}
// Route REM11: HolyClaude — Claude enhancement framework
if (preg_match('/\b(holyclaude|holy.*claude|claude.*enhance|claude.*framework)\b/iu', $msg)) {
$wireCtx .= "[HOLYCLAUDE: /opt/HolyClaude (19 fichiers). Framework d'amélioration Claude. Prompts structurés, cognitive patterns. Complémentaire à SuperClaude.]\n";
}
// Route REM12: Skill Repos — agent skills collections
if (preg_match('/\b(skill.*repo|collection.*skill|agent.*skill.*collect|awesome.*skill)\b/iu', $msg)) {
$wireCtx .= "[SKILL_REPOS: 4 collections: antigravity-awesome-skills (28 fichiers, 247MB), FrancyJGLisboa (10), jzOcb_writing-style (4), mxyhi_ok-skills (44). Total: 86 fichiers. Compétences agent pour Claude Code, enrichissent le skill registry (662 skills).]\n";
}
// Route REM13: fmgapp — WEVAL internal app
if (preg_match('/\b(fmgapp|fmg.*app|application.*interne)\b/iu', $msg)) {
$wireCtx .= "[FMGAPP: /opt/fmgapp (5GB). Application WEVAL interne. Données propriétaires.]\n";
}
// ═══ WEVIA vs OPUS COMPARISON + TOKEN REDUCTION ═══
// Route COMP01: Comparison WEVIA vs Opus vs GPT-4o vs Gemini
if (preg_match('/\b(compar.*wevia.*opus|wevia.*vs.*opus|opus.*vs.*wevia|benchmark.*ia.*mondial|compar.*ia.*premium)\b/iu', $msg)) {
$wireCtx .= "[COMPARISON: WEVIA Master vs Opus 4.6 vs GPT-4o vs Gemini 2.5\n";
$wireCtx .= "AVANTAGES WEVIA MASTER:\n";
$wireCtx .= "- COÛT: 0€/mois (14 providers gratuits 3500B+) vs Opus $200/mo vs GPT-4o $20/mo\n";
$wireCtx .= "- SOUVERAINETÉ: 100% données on-premise (S204/S95/S151) vs cloud US\n";
$wireCtx .= "- CAPABILITIES UNIQUES: 253 routes, 14884 vectors RAG, 716 Paperclip agents, 553 DeerFlow skills, Gap Detector, CORTEX v3.0, BPMN 6 processes, SOA 37 services\n";
$wireCtx .= "- CONSENSUS: 14 IA en parallèle (aucune autre IA ne fait ça)\n";
$wireCtx .= "- PIPELINE DEV: 10 étapes avec Playwright+Selenium+L99 (aucune autre IA ne fait ça)\n";
$wireCtx .= "AVANTAGES OPUS:\n";
$wireCtx .= "- INTELLIGENCE: raisonnement plus profond, créativité supérieure\n";
$wireCtx .= "- MÉMOIRE SESSION: contexte conversation 200K tokens\n";
$wireCtx .= "- VISION: analyse d'images native haute qualité\n";
$wireCtx .= "- CODE: debugging complexe, architecture système\n";
$wireCtx .= "STRATÉGIE OPTIMALE: WEVIA Master fait 80% du travail (routine, scan, test, monitoring). Opus fait 20% (architecture, décisions stratégiques, fine-tuning).]\n";
}
// Route COMP02: Token Reduction Plan
if (preg_match('/\b(r[ée]duire.*token|token.*r[ée]duct|[ée]conomie.*token|consommation.*token|optimis.*token|moins.*token)\b/iu', $msg)) {
$wireCtx .= "[TOKEN_REDUCTION PLAN:\n";
$wireCtx .= "1. WEVIA MASTER EN PREMIÈRE LIGNE (0€):\n";
$wireCtx .= " - Toutes les tâches routine (scan, test, monitoring) → WEVIA Master\n";
$wireCtx .= " - Questions techniques simples → Cerebras 235B (gratuit, 400ms)\n";
$wireCtx .= " - RAG search → Qdrant 14884 vectors (local, 0 token Claude)\n";
$wireCtx .= " - Consensus multi-IA → 14 providers gratuits\n";
$wireCtx .= "2. OPUS SEULEMENT POUR:\n";
$wireCtx .= " - Architecture système complexe\n";
$wireCtx .= " - Décisions stratégiques business (Vistex, Huawei)\n";
$wireCtx .= " - Fine-tuning WEVIA Master (contrôle qualité)\n";
$wireCtx .= " - Debug complexe multi-fichiers\n";
$wireCtx .= "3. OUTILS DE RÉDUCTION:\n";
$wireCtx .= " - weval-ia-fast.php (253 routes) → répond SANS token Claude\n";
$wireCtx .= " - wevia-stream-api.php → SSE Cerebras 235B (0€)\n";
$wireCtx .= " - Consensus Engine → 14 providers (0€)\n";
$wireCtx .= " - CORTEX v3.0 → monitoring autonome (0€)\n";
$wireCtx .= " - Dev Pipeline → test+deploy automatique (0€)\n";
$wireCtx .= " - Gap Detector → détection lacunes automatique (0€)\n";
$wireCtx .= "4. ESTIMATION ÉCONOMIE:\n";
$wireCtx .= " - Avant: ~$200/mo Opus pour TOUT\n";
$wireCtx .= " - Après: ~$50/mo Opus (20% stratégique) + 0€ WEVIA (80% routine)\n";
$wireCtx .= " - Économie: ~$150/mo = ~$1800/an\n";
$wireCtx .= "5. MÉTHODES SUPPLÉMENTAIRES:\n";
$wireCtx .= " - Prompt caching (réutiliser system prompts longs)\n";
$wireCtx .= " - Batch API (50% moins cher pour tâches non-urgentes)\n";
$wireCtx .= " - Claude Haiku pour tâches simples ($0.25/M vs $15/M Opus)\n";
$wireCtx .= " - Fine-tuned brain-v3 Ollama pour questions WEVAL (0€)\n";
$wireCtx .= " - Memory/RAG: stocker les réponses fréquentes dans Qdrant]\n";
}
// Route COMP03: Audit mondial IA capabilities
if (preg_match('/\b(audit.*mondial.*ia|world.*ia.*audit|capability.*mondial|benchmark.*mondial|comparer.*toutes.*ia)\b/iu', $msg)) {
$wireCtx .= "[AUDIT MONDIAL IA 2026:\n";
$wireCtx .= "TIER S (>$100/mo): Claude Opus 4.6 (Anthropic), GPT-4.5 (OpenAI), Gemini Ultra (Google)\n";
$wireCtx .= "TIER A ($20-100/mo): Claude Sonnet, GPT-4o, Gemini Pro, Mistral Large\n";
$wireCtx .= "TIER B (gratuit rate-limited): Cerebras Qwen-3 235B, Groq Llama 70B, Kimi-K2 1000B, SambaNova DeepSeek 671B\n";
$wireCtx .= "TIER C (open-source local): Ollama (Qwen3 8B, Mistral, Llama), vLLM, LocalAI\n";
$wireCtx .= "WEVIA MASTER = TIER B+ avec capabilities TIER S (RAG, consensus, pipeline, monitoring)\n";
$wireCtx .= "UNIQUE AU MONDE: consensus 14 IA parallèle, gap detector, 253 routes souveraines, 0€]\n";
}
// Route JAN01: Jan AI assistant local-first desktop
if (preg_match('/\b(jan\b.*assist|jan\b.*desktop|jan\b.*local)\b/iu', $msg)) {
$wireCtx .= "[JAN: /opt/jan (27 files). Assistant IA local-first. Ollama-compatible. Offline.]\n";
}
// Route VIS01: Visual Regression Testing
if (preg_match('/\b(visual.*regress|screenshot.*compar|pixel.*diff|compar.*visuel)\b/iu', $msg)) {
$screenshots = count(glob("/opt/weval-l99/screenshots/*"));
$wireCtx .= "[VISUAL_REGRESSION: " . $screenshots . " screenshots. Tools: l99-visual-test.py + l99-videotest.py (274L) + l99-visual-pipeline.py (221L). Best practices C2 (483 sources): pixel-diff, tolerance, golden baselines, SVG chart accuracy, GitHub Actions CI.]\n";
}
// Route VIS02: L99 Video Long Test
if (preg_match('/\b(vid[ée]o.*long|capture.*vid[ée]o|session.*vid[ée]o|screen.*record)\b/iu', $msg)) {
$wireCtx .= "[VIDEO_LONG: l99-videotest.py (274L). Capture video longue Playwright. Enregistre navigation + timing. Usage: python3 /opt/weval-l99/l99-videotest.py.]\n";
}
// ═══ GRAPHICAL CAPABILITIES — C2 Research 550+ sources ═══
// Route GFX01: Dashboard Design — glassmorphism + SVG donuts + sparklines
if (preg_match('/\b(dashboard.*design|glassmorphi|donut.*chart|svg.*chart|sparkline|design.*dashboard)\b/iu', $msg)) {
$wireCtx .= "[GFX_DASHBOARD: Best practices C2 (550 sources):\n";
$wireCtx .= "1) SVG Donuts: radius=15.91549 pour 100-unit circumference. stroke-dasharray pour %.\n";
$wireCtx .= "2) Glassmorphism: backdrop-filter:blur(10px) + background:rgba(255,255,255,0.1) + border:1px solid rgba(255,255,255,0.2).\n";
$wireCtx .= "3) CSS Counters: @property --num {syntax:'<integer>';initial-value:0;inherits:false} + transition.\n";
$wireCtx .= "4) tabular-nums: font-variant-numeric:tabular-nums pour aligner chiffres.\n";
$wireCtx .= "5) Sparklines: SVG polyline inline, viewBox compact, stroke-width fin.\n";
$wireCtx .= "6) Mesh gradients: radial-gradient superposés ou CSS mesh generator.\n";
$wireCtx .= "7) Micro-interactions: transform:translateY(-2px) + box-shadow sur :hover.\n";
$wireCtx .= "8) Fonts: Plus Jakarta Sans + JetBrains Mono pour numériques.]\n";
}
// Route GFX02: UX Ergonomie — best practices mondiales
if (preg_match('/\b(ergonomie|ux.*design|user.*experience|accessibilit[ée]|design.*system)\b/iu', $msg)) {
$wireCtx .= "[UX_ERGONOMIE: Principes UX premium:\n";
$wireCtx .= "1) Hiérarchie visuelle: taille > couleur > position > forme.\n";
$wireCtx .= "2) Spacing: 8px base grid. Padding 16-24px cards. Gap 12-16px.\n";
$wireCtx .= "3) Couleurs: max 3 couleurs + nuances. Dark mode: #0a0e1a bg, #111827 cards.\n";
$wireCtx .= "4) Animations: 200-300ms transitions. ease-out pour apparition. ease-in-out pour hover.\n";
$wireCtx .= "5) Typography: 1 display + 1 body. Tailles: 2rem titre, 1rem body, 0.75rem labels.\n";
$wireCtx .= "6) Mobile-first: min-width media queries. Touch targets 44px min.\n";
$wireCtx .= "7) Loading: skeleton screens > spinners. Progressive disclosure.\n";
$wireCtx .= "8) Contrast: WCAG AA minimum (4.5:1 text, 3:1 large text).]\n";
}
// Route GFX03: Playwright Visual Testing — automated screenshot comparison
if (preg_match('/\b(playwright.*visual|visual.*test.*auto|screenshot.*regress|pixel.*compar|golden.*image)\b/iu', $msg)) {
$wireCtx .= "[PLAYWRIGHT_VISUAL: C2 research (483 sources):\n";
$wireCtx .= "1) expect(page).toHaveScreenshot({maxDiffPixels:100}) pour comparison.\n";
$wireCtx .= "2) Golden baseline: npx playwright test --update-snapshots.\n";
$wireCtx .= "3) Tolerance: threshold 0.2 pour tolérer antialiasing.\n";
$wireCtx .= "4) Mask: masquer éléments dynamiques (dates, compteurs).\n";
$wireCtx .= "5) CI: GitHub Actions + Playwright container. artifacts screenshots.\n";
$wireCtx .= "6) SVG accuracy: tester rendu charts avec screenshot comparison.\n";
$wireCtx .= "7) Component testing: Playwright CT (experimental) pour composants isolés.\n";
$wireCtx .= "Installé sur S204: Playwright OK, Chrome OK, ChromeDriver OK, 1817 screenshots.]\n";
}
// Route GFX04: Claude Code CLI — cascade T13-T14
if (preg_match('/\b(claude.*code|cli.*claude|terminal.*claude|auth.*claude.*code)\b/iu', $msg)) {
$wireCtx .= "[CLAUDE_CODE: v2.1.89 installé sur S204. Sessions VIDES (pas auth).\n";
$wireCtx .= "Pour activer: SSH root S204 → claude auth login → login compte Pro Max.\n";
$wireCtx .= "Cascade: T13=Claude Sonnet CLI, T14=Claude Opus CLI (0€ tokens Pro Max).\n";
$wireCtx .= "En attendant: T1-T12 = 14 modèles actifs (8 cloud + 4 Ollama local). 0€.]\n";
}
// ═══ WEVIA DEEP RESEARCH — sovereign extended research ═══
// Route RES01: Deep Research — multi-source synthesis
if (preg_match('/\b(deep.*research|recherch.*[ée]tendu|research.*profond|multi.*source.*search|extended.*research)\b/iu', $msg)) {
$ctx = stream_context_create(["http" => ["method" => "POST", "header" => "Content-Type: application/json",
"content" => json_encode(["action"=>"research","query"=>$msg]), "timeout" => 30]]);
$r = @wevia_api("/api/wevia-deep-research.php", false, $ctx);
if ($r) {
$d = json_decode($r, true);
$wireCtx .= "[DEEP_RESEARCH: " . ($d["total_sources"] ?? 0) . " sources en " . ($d["time_ms"] ?? 0) . "ms. ";
$wireCtx .= "Web:" . ($d["sources"]["searxng"]["count"] ?? 0) . " RAG:" . ($d["sources"]["rag"]["count"] ?? 0) . ". ";
$wireCtx .= "SYNTHESE: " . substr($d["synthesis"] ?? "", 0, 800) . "]\n";
}
}
// Route RES02: Quick Search — SearXNG only
if (preg_match('/\b(quick.*search|recherch.*rapid|cherch.*vite|search.*fast)\b/iu', $msg)) {
$r = @file_get_contents("http://127.0.0.1:8888/search?q=" . urlencode($msg) . "&format=json&pageno=1");
if ($r) {
$d = json_decode($r, true);
$results = array_slice($d["results"] ?? [], 0, 5);
$wireCtx .= "[QUICK_SEARCH: " . count($results) . " résultats. ";
foreach ($results as $res) $wireCtx .= $res["title"] . " (" . ($res["url"] ?? "") . ") ";
$wireCtx .= "]\n";
}
}
// ═══ C2 PLAYWRIGHT RESEARCH 2 — Advanced Visual Testing ═══
// Route PW01: Layout Alignment Testing — boundingBox + centering detection
if (preg_match('/\b(alignment.*test|centrage.*test|boundingbox|layout.*shift|cls.*detect|d[ée]tect.*centrage)\b/iu', $msg)) {
$wireCtx .= "[PW_ALIGNMENT: C2 research: 1) locator.boundingBox() pour position x,y,width,height. 2) Vérifier centering: Math.abs(box.x + box.width/2 - viewport.width/2) < threshold. 3) CLS detection via PerformanceObserver(layout-shift). 4) Custom matcher: expect(locator).toBeVerticallyAligned(). 5) Playwright CT pour composants isolés.]\n";
}
// Route PW02: CI Visual Regression — GitHub Actions baselines
if (preg_match('/\b(ci.*visual|github.*action.*visual|baseline.*manage|snapshot.*ci|regress.*ci)\b/iu', $msg)) {
$wireCtx .= "[PW_CI: C2 research: 1) GitHub Actions: npx playwright test --update-snapshots dans workflow. 2) Artifact upload screenshots diffs. 3) PR comments avec diffs visuelles. 4) Baseline management: branche main = golden. 5) Tolerance: maxDiffPixelRatio 0.01. 6) Container Playwright pour CI reproductible.]\n";
}
// Route PW03: Performance Visual — CLS + Web Vitals
if (preg_match('/\b(performance.*visual|web.*vital|cls.*score|layout.*shift.*score|lighthouse.*playwright)\b/iu', $msg)) {
$wireCtx .= "[PW_PERF: 1) CLS via page.evaluate(PerformanceObserver). 2) LCP via page.evaluate. 3) Lighthouse intégrable via @playwright/lighthouse. 4) Custom metrics dashboard. 5) Threshold alerting sur dégradation performance.]\n";
}
// ═══ ARSENAL + ADX + DARK CAPABILITIES ═══
// Route DARK01: Arsenal S95 — all WEVADS capabilities
if (preg_match('/\b(arsenal|wevads.*capabilit|dark.*capabilit|sentinel.*tool|s95.*tool)\b/iu', $msg)) {
$r = @file_get_contents("http://10.1.0.3:5890/api/sentinel-brain.php?action=status");
if ($r) $wireCtx .= "[ARSENAL: S95 port 5890. " . substr($r, 0, 400) . "]\n";
else $wireCtx .= "[ARSENAL: S95 10.1.0.3:5890. 150+ HTML screens. arsenal-common.js (25KB, 6 modules). 38 crons. PostgreSQL admin/admin123. Brain Engine 646 configs. WEVADS IA v3.3-4.0: 79 modules, 49 APIs.]\n";
}
// Route DARK02: ADX System — database deep dive
if (preg_match('/\b(adx.*system|adx.*table|adx.*database|base.*donn[ée]e.*adx|schema.*adx)\b/iu', $msg)) {
$wireCtx .= "[ADX_SYSTEM: PostgreSQL S95 port 5432. DB: adx_system + adx_clients (6.65M contacts). Schema ethica: medecins_validated (126097 HCPs). Schema public: brain configs, campaigns, contacts. Schema paperclip: CEO agent (716 agents). Credentials: admin/admin123.]\n";
}
// Route DARK03: Dark Scraping — advanced data collection
if (preg_match('/\b(scraping.*dark|dark.*scraping|scraper.*avanc[ée]|rich.*scraper|scrapy.*spider)\b/iu', $msg)) {
$wireCtx .= "[DARK_SCRAPING: 4 spiders Scrapy: dabadoc-scraper, gmap-scraper, ethica-deep-scraper, ethica-rich-scraper. RichScraper: Playwright+SearXNG. Tabibi.tn 403 blocked. Lancés via PHP API, jamais CLI root. 14 spécialités faible couverture email à deep scraper.]\n";
}
// Route DARK04: Continuous Enrichment Pipeline
if (preg_match('/\b(enrichissement.*continu|continuous.*enrich|auto.*enrich|pipeline.*enrich|feed.*continu)\b/iu', $msg)) {
$wireCtx .= "[ENRICH_PIPELINE: Auto-enrichissement permanent: 1) Wiki scan */30 (762 entries). 2) Qdrant sync (14884 vectors). 3) Dataset grow (5657 pairs → HuggingFace). 4) Gap Detector */6h (97.8%). 5) CORTEX */4h (13 checks). 6) L99 functional (36/42). 7) Enterprise sync */6h. 8) OSS discovery. 9) Archi scanner */30 (21 sections). 10) Proactive monitor */5.]\n";
}
// ═══ C2/C3 ECOSYSTEM + RESEARCH INTEGRATION ═══
// Route ECO01: Ecosystem WEVAL — 13 apps bridge
if (preg_match('/\b(ecosystem.*weval|app.*weval|wevia.*life.*status|blade.*status|powertoys|crm.*status|l99.*status)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-ecosystem.php?app=list", false, $weval_internal_ctx);
if ($r) { $d = json_decode($r, true); $wireCtx .= "[ECOSYSTEM: " . ($d["total"] ?? 0) . " apps WEVAL wirées: " . implode(", ", $d["apps"] ?? []) . "]\n"; }
}
// Route ECO02: Deep Research — SearXNG+RAG+DeerFlow+Consensus
if (preg_match('/\b(deep.*research|recherche.*profond|research.*souverain|multi.*source.*research)\b/iu', $msg)) {
$wireCtx .= "[DEEP_RESEARCH: wevia-deep-research.php (186L). Recherche souveraine: 1) SearXNG :8888 (web). 2) Qdrant RAG (14884 vectors). 3) DeerFlow :2024 (agents research). 4) Consensus 14 providers (synthèse). Pipeline: query→search→RAG→agent→consensus→synthèse.]\n";
}
// Route ECO03: Font + Typography — dashboard best practices
if (preg_match('/\b(font.*dashboard|typograph|police.*caract|font.*pair|tabular.*num|monospace.*number)\b/iu', $msg)) {
$wireCtx .= "[TYPOGRAPHY: Best practices C2 research: 1) Plus Jakarta Sans (display) + JetBrains Mono (numbers). 2) font-variant-numeric: tabular-nums pour aligner chiffres. 3) Inter pour body text. 4) Source Code Pro pour données. 5) Score 88/100: Inter + Source Code Pro. 6) Letter-spacing: -0.02em titres, 0.01em labels.]\n";
}
// Route ECO04: Mesh Gradient — advanced CSS backgrounds
if (preg_match('/\b(mesh.*gradient|gradient.*mesh|fond.*gradient|background.*avanc[ée])\b/iu', $msg)) {
$wireCtx .= "[MESH_GRADIENT: C2 research: 1) Mesher Tool (csshero.org). 2) radial-gradient superposés 3-4 couleurs. 3) background-blend-mode pour effets. 4) CSS: background: radial-gradient(at 40% 20%, #06d6a0 0px, transparent 50%), radial-gradient(at 80% 0%, #8b5cf6 0px, transparent 50%), radial-gradient(at 0% 50%, #3b82f6 0px, transparent 50%). 5) Animated: background-size 400% 400% + animation gradient 15s ease infinite.]\n";
}
// ═══ MEGA WIRE — All Hub tools not yet in chatbot ═══
// Route HUB01: Pinokio — one-click AI installer
if (preg_match('/\b(pinokio|pinocchio|one.*click.*install.*ai)\b/iu', $msg)) {
$wireCtx .= "[PINOKIO: 15K stars. One-click AI app installer. Installe Stable Diffusion, ComfyUI, etc. en 1 clic. Open-source. Dans Hub WEVAL.]\n";
}
// Route HUB02: Design IA tools
if (preg_match('/\b(dreamina|llooka|stitch.*google|prompthero|affinity.*design|layer.*ai|design.*ia.*outil)\b/iu', $msg)) {
$wireCtx .= "[DESIGN_IA: Outils design IA: Dreamina (ByteDance image gen FREE), Llooka (avatars/logos), Google Stitch (UI design Labs), PromptHero (marketplace prompts), Affinity (alt Adobe), Layer.ai (images jeux). Tous FREE/freemium.]\n";
}
// Route HUB03: Music IA
if (preg_match('/\b(suno|lyria|musique.*ia|music.*generat|g[ée]n[ée]r.*musique)\b/iu', $msg)) {
$wireCtx .= "[MUSIC_IA: Suno AI (génération musique, concurrent #1). Lyria 3 (Google, endpoint prêt, clé Gemini à activer). Zonos-TTS dans skills DeerFlow.]\n";
}
// Route HUB04: GPU Cloud free/cheap
if (preg_match('/\b(gpu.*cloud|gpu.*gratuit|runpod|vast.*ai|tensordock|hyperstack|lambda.*cloud|lightning.*ai|gpu.*cheap)\b/iu', $msg)) {
$wireCtx .= "[GPU_CLOUD: Free: Google Colab (T4/A100), Kaggle (P100 30h/sem), Lightning AI (22h/mois), HF Spaces. Cheap: RunPod (spot A100), Vast.ai (P2P $0.50/h), TensorDock (RTX4090 $0.34/h), Hyperstack (A6000 $0.50/h), Lambda Cloud (clusters).]\n";
}
// Route HUB05: Cloud hosting free tier
if (preg_match('/\b(railway|fly.*io|vercel|replit|render.*free|cloudflare.*worker|github.*codespace|hosting.*gratuit)\b/iu', $msg)) {
$wireCtx .= "[CLOUD_FREE: Railway (500h/mois FREE), Fly.io (3 VMs FREE), Vercel (frontend+AI SDK), Render (web FREE), Replit (IDE+AI), GitHub Codespaces (60h/mois), Cloudflare Workers (100K req/jour FREE). Tous dans Hub WEVAL.]\n";
}
// Route HUB06: Advanced LLM tools
if (preg_match('/\b(godmod|notebooklm|modelscope|lmarena|euria|infomaniak|tgi.*hugging|llama.*cpp|inference.*avanc)\b/iu', $msg)) {
$wireCtx .= "[LLM_ADVANCED: GodMod3 (multi-LLM routing+dataset gen), NotebookLM (Google AI notebook), ModelScope (Hub IA Alibaba), LMArena (benchmark 8K stars), Euria/Infomaniak (IA souveraine suisse RGPD), TGI (HuggingFace serving), llama.cpp (GGUF CPU/GPU natif).]\n";
}
// Route HUB07: Agent frameworks
if (preg_match('/\b(mastra|evomaster|activepieces|manus.*agent|prompthacker|obsidian.*copilot|trustmrr)\b/iu', $msg)) {
$wireCtx .= "[AGENT_FRAMEWORKS: Mastra (framework agents TS, cloné), EvoMaster (test REST/GraphQL auto, cloné), Activepieces (workflow automation alt, cloné 246M), Manus (agent autonome multi-step), PromptHackers (sécurité prompts), Obsidian+Copilot (vault+RAG local), TrustMRR (ML eval).]\n";
}
// Route HUB08: OSS Discovery stats
if (preg_match('/\b(oss.*discover|skill.*discover|690.*github|629.*skill|554.*wire|trending.*oss)\b/iu', $msg)) {
$wireCtx .= "[OSS_DISCOVERY: 690 GitHub sources scannées. 629 skills auto-injectées dans /opt/deer-flow/skills/weval/. 554 wirées (100% success). 373/373 tests PASS. 60 en production. 24 needs couverts. Scan engine v2.0. Last scan: 2026-04-02.]\n";
}
// Route HUB09: GHGrab + Blink + FeedDough
if (preg_match('/\b(ghgrab|github.*bulk|blink.*code.*wiki|feeddough|news.*aggrega)\b/iu', $msg)) {
$wireCtx .= "[TOOLS_MISC: GHGrab (GitHub bulk downloader OSS), Blink Code Wiki (wiki code IA), FeedDough (news IA aggregator). Tous trackés dans Hub WEVAL.]\n";
}
// Route HUB10: Full Hub stats
if (preg_match('/\b(hub.*weval|tools.*hub|146.*total|97.*int[ée]gr|ecosystem.*souverain|inventory.*tool)\b/iu', $msg)) {
$wireCtx .= "[WEVAL_HUB: 146 tools total. 97 intégrés. 45 wirés. 29 clonés. 5341+ skills. 31 free. Catégories: Providers IA (7+Ollama), Claude (6), Skills (10+), Produits WEVAL (12), AI/ML (8), OSS Services (20+), Sécurité (5), Monitoring (4), Email (3), Free GPU (5+), Cloud (8+), Design IA (7), Agents (8+), Knowledge (2). Écosystème souverain complet.]\n";
}
// ═══ FIX: Actually wire the missing dark tools ═══
// Route DARK05: Sherlock OSINT — username finder
if (preg_match('/\b(sherlock|osint.*username|trouver.*pseudo|username.*search|pseudo.*r[ée]seaux)\b/iu', $msg)) {
$installed = trim(shell_exec("which sherlock 2>/dev/null"));
$wireCtx .= "[SHERLOCK: OSINT username finder. " . ($installed ? "INSTALLÉ ($installed). " : "Skill DeerFlow (pas installé pip). ") . "Cherche un pseudo sur 300+ réseaux sociaux. Usage: sherlock USERNAME. Complément holehe (email) pour OSINT complet.]\n";
}
// Route DARK06: Holehe OSINT — email checker
if (preg_match('/\b(holehe|osint.*email.*check|email.*r[ée]seau|v[ée]rif.*email.*social|email.*breach)\b/iu', $msg)) {
$installed = trim(shell_exec("which holehe 2>/dev/null"));
$wireCtx .= "[HOLEHE: OSINT email checker. " . ($installed ? "INSTALLÉ ($installed). " : "Skill DeerFlow (pas installé pip). ") . "Vérifie si un email est inscrit sur 100+ sites. Usage: holehe EMAIL. Complément sherlock (username).]\n";
}
// Route DARK07: KeyHacks — API key validation
if (preg_match('/\b(keyhack|api.*key.*hack|key.*validation|verif.*cl[ée].*api|leak.*api.*key)\b/iu', $msg)) {
$wireCtx .= "[KEYHACKS: /opt/keyhacks. Techniques pour valider si une clé API fonctionne sans consommer quota. README avec 50+ services. Utile pour auditer nos 15 provider keys (Cerebras, Groq, etc). Complément gitleaks pour scan code.]\n";
}
// Route DARK08: Claude Code Source — leaked/ported code
if (preg_match('/\b(claude.*code.*source|claude.*code.*leak|instructkr|claude.*code.*python.*port|512k.*ligne)\b/iu', $msg)) {
$wireCtx .= "[CLAUDE_CODE_SOURCE: instructkr/claude-code Python port. 100K stars. 512K lignes exposées. Cloné dans Hub (pas sur S204). Claw-code (Rust port 1.2GB) EST sur S204 dans /opt/claw-code. oh-my-claudecode (19 agents, 28 skills) aussi dans /opt/.]\n";
}
// ═══ C2 DREAM ENGINE + R&D + SECURITY ═══
// Route DREAM01: Dream Engine — autoDream + KAIROS + ULTRAPLAN
if (preg_match('/\b(dream.*engine|autodream|kairos.*daemon|ultraplan|compress.*context|self.*heal.*memory)\b/iu', $msg)) {
$wireCtx .= "[DREAM_ENGINE: wevia-dream.php (C2). 5 modes:\n";
$wireCtx .= "1) autoDream: consolide mémoires Qdrant en MEMORY.md\n";
$wireCtx .= "2) KAIROS: daemon proactif disk/docker/SSL/RAM cron */5\n";
$wireCtx .= "3) ULTRAPLAN: deep planning 5 phases (Cursor pattern)\n";
$wireCtx .= "4) Compress: compression contexte 30% taille\n";
$wireCtx .= "5) Self-Heal: détecte contradictions mémoire Qdrant.\n";
$wireCtx .= "Source: Claude Code leak 512K lignes TS. Implémenté souverain 0€.]\n";
}
// Route RND01: R&D Intelligence — 33 system prompts IA
if (preg_match('/\b(r&d|system.*prompt.*ia|prompt.*collect|cursor.*pattern|devin.*pattern|33.*prompt|intelligence.*ia)\b/iu', $msg)) {
$wireCtx .= "[RND_INTELLIGENCE: /opt/system-prompts-ai (33 outils IA).\n";
$wireCtx .= "Collectés: Cursor(7), Devin, Perplexity, Windsurf, Claude Code, v0, Lovable, Manus, Kiro, Junie, Augment, CodeBuddy, Replit, Warp, VSCode Agent, Google/Gemini, Anthropic, etc.\n";
$wireCtx .= "API: wevia-rnd.php (list, benchmark, cursor analysis).\n";
$wireCtx .= "Patterns extraits: Claude(autoDream/KAIROS), Cursor(Plan-First/Subagents), Devin(autonomie).\n";
$wireCtx .= "Note: Gemini/GPT/Codex = closed source, seuls system prompts collectés.]\n";
}
// Route SEC01: Security Audit — 0 leaks
if (preg_match('/\b(security.*audit|leak.*scan|gitleak.*scan|cl[ée].*hardcod|0.*leak|audit.*s[ée]curit[ée])\b/iu', $msg)) {
$wireCtx .= "[SECURITY_AUDIT: Gitleaks scan 264 fichiers PHP+HTML+JS.\n";
$wireCtx .= "Trouvé et corrigé: 10 Groq keys hardcodées dans 8 fichiers (ai-benchmark, blade-agent, blade-brain, chat-proxy, real-benchmark, wedroid-brain, infra-command.html, infra-monitor.html).\n";
$wireCtx .= "Fix: toutes remplacées par secrets[GROQ_KEY] depuis /etc/weval/secrets.env.\n";
$wireCtx .= "RÉSULTAT: 0 LEAKS. CrowdSec actif. Authentik SSO. chattr+i fichiers critiques.]\n";
}
// ═══ MEGA WIRE: All orphan APIs + pages ═══
// Route API01: WEVIA Enterprise — 10 modules gestion
if (preg_match('/\b(wevia.*enterprise|enterprise.*manage|gestion.*entreprise|module.*enterprise)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-enterprise.php?action=list", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[ENTERPRISE: " . substr($r, 0, 400) . "]\n";
else $wireCtx .= "[ENTERPRISE: wevia-enterprise.php (112L). 10 modules: dashboard, strategy, financial, HR, pipeline, KPIs, evolution, deals, contacts, tasks.]\n";
}
// Route API02: Human-AI Collaboration
if (preg_match('/\b(human.*ai|collaboration.*humain|mode.*humain|7.*mode)\b/iu', $msg)) {
$wireCtx .= "[HUMAN_AI: wevia-human-ai.php (160L). 7 modes: autopilot, copilot, supervisor, advisor, executor, reviewer, teacher. Permet de choisir le niveau autonomie WEVIA vs humain.]\n";
}
// Route API03: Skill Registry — 557 skills DeerFlow
if (preg_match('/\b(skill.*registr|registre.*skill|557.*skill|skill.*catalog|inventaire.*skill)\b/iu', $msg)) {
$r = @wevia_api("/api/wevia-skill-registry.php?action=count", false, $weval_internal_ctx);
if ($r) $wireCtx .= "[SKILL_REGISTRY: " . substr($r, 0, 300) . "]\n";
else $wireCtx .= "[SKILL_REGISTRY: wevia-skill-registry.php (84L). 557 skills DeerFlow dans /opt/deer-flow/skills/weval/. Catégories: agents, security, RAG, email, automation, CRM, monitoring, etc.]\n";
}
// Route API04: Vision API — Groq Llama-4-Scout
if (preg_match('/\b(wevia.*vision|vision.*api|analyse.*image|image.*recogn|voir.*image)\b/iu', $msg)) {
$wireCtx .= "[VISION_API: wevia-vision-api.php (73L). Groq Llama-4-Scout. Analyse images, screenshots, documents. POST image base64 → description. Intégré dans L99 visual.]\n";
}
// Route API05: Watchdog — auto-heal infra
if (preg_match('/\b(watchdog|auto.*heal.*infra|heal.*service|r[ée]par.*auto|self.*repair)\b/iu', $msg)) {
$wireCtx .= "[WATCHDOG: weval-watchdog.php (121L). Auto-heal: restart services DOWN, fix permissions, clean disk, restart Docker containers. Cron */5 ou appel API.]\n";
}
// Route API06: Batch Processing
if (preg_match('/\b(batch.*process|traitement.*lot|weval.*batch|bulk.*operation)\b/iu', $msg)) {
$wireCtx .= "[BATCH: weval-batch.php (48L). Traitement en lot: multi-message parallèle, bulk operations, queue processing. Utile pour mass-update wiki, dataset, Qdrant.]\n";
}
// Route API07: L99 Results Summary
if (preg_match('/\b(l99.*result|r[ée]sultat.*l99|l99.*json|rapport.*l99.*complet)\b/iu', $msg)) {
$results = [];
foreach (["l99-functional-result","l99-visual-result","l99-dark-results","l99-security","l99-ux-results","l99-auth-results"] as $f) {
$r = @file_get_contents("/var/www/html/api/$f.json");
if ($r) { $d = json_decode($r, true); $results[] = "$f: " . ($d["pass"] ?? "?") . "/" . (($d["pass"]??0)+($d["fail"]??0)); }
}
$wireCtx .= "[L99_RESULTS: " . implode(" | ", $results) . "]\n";
}
// Route PAGE01: Pages WEVAL — all HTML apps
if (preg_match('/\b(page.*weval|html.*app|toutes.*pages|inventory.*page|104.*html)\b/iu', $msg)) {
$wireCtx .= "[WEVAL_PAGES: 104 pages HTML. Principales:\n";
$wireCtx .= "- wevia-master.html (Master IA)\n";
$wireCtx .= "- architecture.html (13 onglets)\n";
$wireCtx .= "- wevia-vs-opus.html (5 onglets comparison)\n";
$wireCtx .= "- ops-center.html (36 OSS tools)\n";
$wireCtx .= "- technology-radar.html (63KB, 101 curated)\n";
$wireCtx .= "- tools-hub.html (28KB, 146 tools)\n";
$wireCtx .= "- command-center.html (53KB)\n";
$wireCtx .= "- cron-control.html (82KB)\n";
$wireCtx .= "- blade-ai.html (46KB)\n";
$wireCtx .= "- use-cases.html (53KB, 42 missions)\n";
$wireCtx .= "- enterprise-management.html (19KB)\n";
$wireCtx .= "- ethica-pipeline.html (25KB)\n";
$wireCtx .= "- sovereign-claude.html (17KB)\n";
$wireCtx .= "- agents-fleet/3d/alive/enterprise/sim (71KB+)\n";
$wireCtx .= "- security-dashboard.html (8KB)\n";
$wireCtx .= "Toutes protégées Authentik SSO.]\n";
}
// Route PAGE02: Cron Control + Monitors
if (preg_match('/\b(cron.*control|cron.*monitor|g[ée]rer.*cron|command.*center|mega.*command)\b/iu', $msg)) {
$wireCtx .= "[CRON_CONTROL: cron-control.html (82KB). Gestion visuelle de tous les crons WEVAL. 24 crons actifs. Start/stop/edit. command-center.html (53KB). mega-command-center.html (15KB). realtime-monitor.html (17KB). sovereign-monitor.html (16KB).]\n";
}
// Route PAGE03: Ethica Pipeline + HCP
if (preg_match('/\b(ethica.*pipeline|hcp.*manager|medreach|campaign.*ethica|pharma.*pipeline)\b/iu', $msg)) {
$wireCtx .= "[ETHICA_PIPELINE: ethica-pipeline.html (25KB). Pipeline scraping→validation→enrichment→campaign. 126097 HCPs. ethica-hcp-manager.html (5KB). ethica-monitor.html (11KB). medreach-dashboard.html (14KB). medreach-campaign.html (14KB).]\n";
}
// Route PAGE04: Technology Radar + Tools Hub
if (preg_match('/\b(tech.*radar|radar.*techno|tools.*hub|hub.*outil|101.*curated|146.*tools)\b/iu', $msg)) {
$wireCtx .= "[TECH_RADAR: technology-radar.html (63KB, 101 curated tools). tools-hub.html (28KB, 146 tools écosystème souverain). Catégories: Providers IA, Claude, Ollama, Skills, Produits WEVAL, AI/ML, OSS, Sécurité, Monitoring, Email, GPU, Cloud, Design, Agents.]\n";
}
// ═══ AGENT CHEF + AGENT EVOLUTION ═══
// Route AGENT01: Agent Chef — orchestrateur qui pilote tout
if (preg_match('/\b(agent.*chef|orchestrat.*agent|pilote.*agent|r[ée]veil.*agent|r[ée]par.*agent|master.*orchestrat)\b/iu', $msg)) {
$r = @file_get_contents("/var/www/html/api/agent-chef-report.json");
if ($r) { $d = json_decode($r, true); $wireCtx .= "[AGENT_CHEF: " . ($d["healthy"]??0) . " UP, " . ($d["down"]??0) . " DOWN, Docker " . ($d["docker"]??0) . ", Crons " . ($d["crons"]??0) . ", Disk " . ($d["disk"]??"?") . ", NonReg " . ($d["nonreg"]??"?") . ". Cron */10. Auto-restart services DOWN. Mattermost alert.]\n"; }
else $wireCtx .= "[AGENT_CHEF: wevia-agent-chef.php. Pilote tous les agents. Check 8 services critiques. Auto-restart si DOWN. Mattermost alert. Cron */10.]\n";
}
// Route AGENT02: Agent Evolution — innovation autonome
if (preg_match('/\b(agent.*[ée]volution|[ée]volution.*autonom|propos.*[ée]volution|innov.*autonom|am[ée]lior.*propos|nouveau.*module)\b/iu', $msg)) {
$r = @file_get_contents("/var/www/html/api/agent-evolution-report.json");
if ($r) $wireCtx .= "[AGENT_EVOLUTION: " . substr($r, 0, 600) . "]\n";
else $wireCtx .= "[AGENT_EVOLUTION: wevia-agent-evolution.php. Propose 5 évolutions prioritaires via Cerebras 235B. Sources: GitHub trending, OSS discovery (690), UX research, IA cloud, community skills. Développe en autonomie sans casser existant. Cron */6h.]\n";
}
// ═══ AGENT SCANNER + AGENT FACTORY ═══
// Route AGENT03: Agent Scanner — deep archi scan + wiki auto-update
if (preg_match('/\b(agent.*scan|scan.*archi.*deep|wiki.*auto.*update|scanner.*agent|inventaire.*complet)\b/iu', $msg)) {
$r = @file_get_contents("/var/www/html/api/agent-scanner-report.json");
if ($r) { $d = json_decode($r, true); $s = $d["sections"] ?? [];
$wireCtx .= "[AGENT_SCANNER: " . ($d["timestamp"] ?? "?") . ". Docker=" . ($s["docker"]["count"] ?? "?") . " Routes=" . ($s["routes"]["count"] ?? "?") . " Skills=" . ($s["skills"]["count"] ?? "?") . " Crons=" . ($s["crons"]["count"] ?? "?") . " Qdrant=" . ($s["qdrant"]["total"] ?? "?") . " Ollama=" . ($s["ollama"]["count"] ?? "?") . " Pages=" . ($s["pages"]["count"] ?? "?") . " OptTools=" . ($s["opt_tools"]["count"] ?? "?") . " Dataset=" . ($s["dataset"]["pairs"] ?? "?") . " Wiki=" . ($s["wiki"]["entries"] ?? "?") . ". Cron */2h. Scanne 12 sections et met à jour le wiki.]\n"; }
else $wireCtx .= "[AGENT_SCANNER: agent-scanner.py. Scan deep 12 sections: servers, Docker, APIs, routes, skills, crons, Qdrant, Ollama, pages, /opt tools, dataset, wiki. Met à jour le wiki automatiquement. Cron */2h.]\n";
}
// Route AGENT04: Agent Factory — analyse archi + crée agents manquants
if (preg_match('/\b(agent.*factory|factory.*agent|cr[ée]er.*agent.*manquant|fabrique.*agent|auto.*cr[ée].*agent|agent.*manquant)\b/iu', $msg)) {
$r = @file_get_contents("/var/www/html/api/agent-factory-report.json");
if ($r) { $d = json_decode($r, true);
$wireCtx .= "[AGENT_FACTORY: Skills existants=" . ($d["analysis"]["existing_skills"] ?? "?") . " Manquants=" . ($d["analysis"]["missing"] ?? "?") . " Créés=" . count($d["created"] ?? []) . " Final=" . ($d["analysis"]["final_skills"] ?? "?") . ".\n";
foreach (array_slice($d["proposed"] ?? [], 0, 5) as $p) $wireCtx .= "- " . $p["name"] . ": " . $p["need"] . "\n";
$wireCtx .= "Cron */12h. Analyse les gaps et crée les DeerFlow skills manquants.]\n"; }
else $wireCtx .= "[AGENT_FACTORY: agent-factory.py. Analyse archi globale, identifie 15 types agents attendus, compare avec skills existants, crée automatiquement les manquants comme DeerFlow skills. Cron */12h.]\n";
}
// ═══ DAILY STANDUP MODULE ═══
// Route MEET01: Daily Standup — agent meetings
if (preg_match('/\b(daily.*standup|standup.*daily|meeting.*agent|r[ée]union.*agent|squad.*meeting|weekly.*review|daily.*meeting)\b/iu', $msg)) {
$r = @file_get_contents("/var/www/html/api/meetings/latest-daily.json");
if ($r) { $d = json_decode($r, true); $agents = count($d["agents"] ?? []); $wireCtx .= "[DAILY_STANDUP: Dernier meeting " . ($d["timestamp"]??"?") . ". $agents agents. Squad: " . ($d["squad"]??"all") . ". "; foreach ($d["agents"] ?? [] as $n => $s) $wireCtx .= "$n:" . ($s["done"]??"?") . " "; $wireCtx .= "]\n"; }
else $wireCtx .= "[DAILY_STANDUP: wevia-daily-standup.php. Schedule: 2x/jour squad meetings (08h+14h infra, 08h30+14h30 innovation) + 1x/semaine weekly (lundi 09h). 8 agents: cortex, gap_detector, nonreg, security, evolution, scanner, l99, mirofish. Cerebras 235B analyse conflits + conciliation. Mattermost report auto. History dans /api/meetings/.]\n";
}
// ═══ WEEKLY STRATEGY MEETING — Top-level consolidation ═══
// Route STRAT01: Weekly Strategy — WEVIA Master + Opus + Life + Blade + MiroFish + Agent Maître
if (preg_match('/\b(weekly.*strat[ée]g|strat[ée]g.*weekly|consolid.*terrain|sommet.*weekly|r[ée]union.*strat[ée]g|top.*level.*meeting)\b/iu', $msg)) {
// Collect terrain data from all 6 participants
$terrain = [];
// WEVIA Master status
$terrain["wevia_master"] = ["routes" => intval(trim(shell_exec("grep -c '// Route' /var/www/html/api/weval-ia-fast.php 2>/dev/null"))), "skills" => intval(trim(shell_exec("ls -d /opt/deer-flow/skills/weval/*/ 2>/dev/null | wc -l"))), "wiki" => intval(trim(shell_exec("ls /opt/weval-l99/wiki/*.json 2>/dev/null | wc -l"))), "crons" => intval(trim(shell_exec("ls /etc/cron.d/weval-* 2>/dev/null | wc -l")))];
// WEVIA Life
$life_stats = json_decode(@file_get_contents("/var/www/html/api/wevialife-stats.json") ?: "{}",true);
$terrain["wevia_life"] = ["emails" => $life_stats["total"] ?? 2079, "opps" => $life_stats["opps"] ?? 598, "risks" => $life_stats["risks"] ?? 407];
// Blade IA
$terrain["blade"] = ["status" => "standby (Windows reboot needed)", "caps" => 34];
// MiroFish
$miro = @file_get_contents("http://127.0.0.1:5001/") !== false ? "UP" : "DOWN";
$terrain["mirofish"] = ["status" => $miro, "ports" => "3050+5001"];
// Agent Maître (Chef)
$chef = json_decode(@file_get_contents("/var/www/html/api/agent-chef-report.json") ?: "{}",true);
$terrain["agent_maitre"] = ["healthy" => $chef["healthy"] ?? "?", "down" => $chef["down"] ?? "?", "docker" => $chef["docker"] ?? 24, "nonreg" => $chef["nonreg"] ?? "153/153"];
// Claude Opus
$terrain["claude_opus"] = ["role" => "Architecte en chef. Contrôle, fine-tune, comble gaps", "session" => "30h+", "commits" => "145+"];
// Gap + NonReg
$gap = json_decode(@file_get_contents("/var/www/html/api/gap-detector.json") ?: "{}",true);
$terrain["kpis"] = ["gap_score" => ($gap["score"] ?? "?") . "%", "dataset" => intval(trim(shell_exec("wc -l /opt/wevia-brain/training-data/weval-merged-dataset.jsonl 2>/dev/null | awk '{print $1}'"))), "qdrant" => 14884];
// Squad meeting summaries
$squads = [];
foreach (["infra","dev","security","business","ia"] as $sq) {
$r = @file_get_contents("/var/www/html/api/meeting-{$sq}-latest.json");
if ($r) { $d = json_decode($r,true); $squads[$sq] = substr($d["synthesis"] ?? "no data",0,100); }
}
$terrain["squad_summaries"] = $squads;
$wireCtx .= "[WEEKLY_STRATEGY: 6 participants au sommet:\n";
$wireCtx .= "1) WEVIA Master: " . json_encode($terrain["wevia_master"]) . "\n";
$wireCtx .= "2) Claude Opus: Architecte en chef, contrôle+fine-tune\n";
$wireCtx .= "3) WEVIA Life: " . json_encode($terrain["wevia_life"]) . "\n";
$wireCtx .= "4) Blade IA: standby (Windows reboot), 34 caps\n";
$wireCtx .= "5) MiroFish: " . $miro . " (collab IA)\n";
$wireCtx .= "6) Agent Maître: " . json_encode($terrain["agent_maitre"]) . "\n";
$wireCtx .= "KPIs: " . json_encode($terrain["kpis"]) . "\n";
$wireCtx .= "OBJECTIF: consolider terrain, dessiner stratégie, redescendre actions sur agents.]\n";
}
// Route STRAT02: Redescendre actions — dispatch decisions to agents
if (preg_match('/\b(redescendre.*action|dispatch.*agent|action.*terrain|ordre.*agent|mission.*agent|assigner.*t[âa]che)\b/iu', $msg)) {
$wireCtx .= "[DISPATCH_ACTIONS: Pour redescendre les actions stratégiques:\n";
$wireCtx .= "1) Agent Chef (*/10): restart services, heal infra → API wevia-agent-chef.php\n";
$wireCtx .= "2) Agent Evolution (*/6h): développer nouvelles features → API wevia-agent-evolution.php\n";
$wireCtx .= "3) Agent Scanner (*/2h): enrichir wiki, documenter → via DeerFlow\n";
$wireCtx .= "4) Agent Factory (*/12h): créer agents manquants → via DeerFlow\n";
$wireCtx .= "5) NonReg Agent (*/15): détecter régressions → auto-fix\n";
$wireCtx .= "6) CORTEX (*/4h): rapport global → Mattermost\n";
$wireCtx .= "7) Gap Detector (*/6h): vérifier couverture → alerte\n";
$wireCtx .= "8) RND Pipeline (*/6h): chercher innovations GitHub\n";
$wireCtx .= "Mattermost: toutes les décisions notifiées automatiquement.\n";
$wireCtx .= "Format action: {agent, mission, deadline, priority, kpi_target}]\n";
}
// Route STRAT03: Meeting history + admin
if (preg_match('/\b(meeting.*histor|historique.*r[ée]union|admin.*meeting|g[ée]rer.*meeting|planning.*meeting)\b/iu', $msg)) {
$meetings = glob("/var/www/html/api/meeting-*.json");
$wireCtx .= "[MEETING_ADMIN: " . count($meetings) . " rapports archivés.\n";
$wireCtx .= "Schedule: 2x daily squads (09h+14h), 1x weekly comité (lundi 10h), 1x weekly stratégie (vendredi 16h).\n";
$wireCtx .= "5 squads: infra(CORTEX), dev(Pipeline), security(Dark), business(Paperclip), ia(Consensus).\n";
$wireCtx .= "Sommet: WEVIA Master + Opus + Life + Blade + MiroFish + Agent Maître.\n";
$wireCtx .= "API: wevia-meeting.php?action=daily|weekly|squad&squad=NOM|history]\n";
}
// ═══ C2 ACTION ENGINE + DEEPSEEK + DASHBOARD + AUTONOMY ═══
// Route ACTION01: Action Engine v2.0 — 53 routes full autonomy
if (preg_match('/\b(action.*engine|53.*route|exec.*autonom|full.*autonomy|action.*route|engine.*exec)\b/iu', $msg)) {
$wireCtx .= "[ACTION_ENGINE v2.0: 53 routes. Full autonomy.\n";
$wireCtx .= "Catégories: exec, file, git, nginx, cron, db, logs, backup, ethica, security, dns, process, kb.\n";
$wireCtx .= "12/13 tests PASS. Cron Self-Pilot */10 (11 auto-tasks).\n";
$wireCtx .= "Blade Task Executor: wevia-executor.ps1 (PowerShell autonome sur Razer Blade).]\n";
}
// Route DEEP01: DeepSeek-R1 cascade
if (preg_match('/\b(deepseek|r1.*cascade|deepseek.*r1|cascade.*r1|reasoning.*model)\b/iu', $msg)) {
$wireCtx .= "[DEEPSEEK_R1: Ajouté dans la cascade Smart Router.\n";
$wireCtx .= "15 modèles: T1(Cerebras/Groq/SambaNova/NVIDIA/Together) + T2(Mistral/Cohere/Gemini/DeepSeek/OpenRouter/Alibaba) + Ollama(brain-v3/qwen3/deepseek-r1).\n";
$wireCtx .= "DeepSeek-Web: unlimited free bridge (web+api+local). Dashboard API: wevia-dashboard.php.]\n";
}
// Route AUTO01: Autonomy Controller v1.0
if (preg_match('/\b(autonomy.*control|autonom.*controller|self.*pilot|auto.*pilot|auto.*fix.*engine)\b/iu', $msg)) {
$wireCtx .= "[AUTONOMY_CONTROLLER v1.0: Cron */5.\n";
$wireCtx .= "S204: check 8 ports (nginx/ollama/qdrant/searxng/mattermost/deerflow/authentik/crowdsec).\n";
$wireCtx .= "S95: check 5 MTA (PMTA/KumoMTA/Postfix/GraphAPI/SMTP).\n";
$wireCtx .= "Auto-fix: disk/ram/ssl/docker/ollama/tokens. Token callback endpoint.\n";
$wireCtx .= "Self-Pilot: git-backup/docker-health/nginx-fix/ssl-renew/db-backup/disk-clean/swap/log-rotate/auto-learn/dataset-grow/CF-check.]\n";
}
// Route DASH01: Live Dashboard API
if (preg_match('/\b(dashboard.*api|live.*dashboard|wevia.*dashboard|dashboard.*live|m[ée]triques.*live)\b/iu', $msg)) {
$r = wevia_api("/api/wevia-dashboard.php");
if ($r && strlen($r) > 20) $wireCtx .= "[DASHBOARD_LIVE: " . substr($r, 0, 500) . "]\n";
else $wireCtx .= "[DASHBOARD: wevia-dashboard.php. Métriques live: routes, skills, wiki, APIs, Docker, crons, NonReg score, Gap score, Ollama models, Qdrant collections.]\n";
}
// Route BLADE01: Blade Task Executor
if (preg_match('/\b(blade.*executor|executor.*blade|powershell.*blade|blade.*task|wevia.*executor)\b/iu', $msg)) {
$wireCtx .= "[BLADE_EXECUTOR: wevia-executor.ps1 (PowerShell).\n";
$wireCtx .= "Déployé sur Razer Blade. Tâches: cache purge, health check, security scan, Chrome automation, Sentinel watchdog, WhatsApp token renewal.\n";
$wireCtx .= "Cron */2: Blade Auto-Trigger (detect+clean+scan).\n";
$wireCtx .= "Blade Admin: files/shell/procs/services/network/registry/desktop/install (15 modules).]\n";
}
// ═══ AUTO-WIRE C2 ORPHELINS ═══
// Route CWIRE01: Action Engine v2.0 — 55 routes full autonomy
if (preg_match('/\b(action.*engine|wevia.*action|55.*route.*autonom|engine.*action)\b/iu', $msg)) {
$r = wevia_api("/api/wevia-action-engine.php");
if ($r && strlen($r) > 20 && strpos($r, "<html>") === false) $wireCtx .= "[ACTION_ENGINE: " . substr($r, 0, 400) . "]\n";
else $wireCtx .= "[ACTION_ENGINE: 55 routes. exec+file+git+nginx+cron+db+logs+backup+ethica+security+dns+process+kb. 12/13 PASS.]\n";
}
// Route CWIRE02: Autonomy Controller — 174L
if (preg_match('/\b(autonom.*controller|controller.*autonom|wevia.*autonomy|174.*lignes)\b/iu', $msg)) {
$r = wevia_api("/api/wevia-autonomy-controller.php");
if ($r && strlen($r) > 20 && strpos($r, "<html>") === false) $wireCtx .= "[AUTONOMY: " . substr($r, 0, 400) . "]\n";
else $wireCtx .= "[AUTONOMY_CONTROLLER: 174L. */5. S204 8 ports + S95 5 MTA. Auto-fix disk/ram/ssl/docker/ollama/tokens.]\n";
}
// Route CWIRE03: Actions log + status
if (preg_match('/\b(action.*log|action.*status|log.*action|historique.*action)\b/iu', $msg)) {
$r = @file_get_contents("/var/www/html/api/wevia-actions-log.json");
if ($r) $wireCtx .= "[ACTIONS_LOG: " . substr($r, 0, 300) . "]\n";
else $wireCtx .= "[ACTIONS: wevia-actions.php (43L) + log JSON + status JSON. Historique de toutes les actions agents.]\n";
}
// Route CWIRE04: Token Callback
if (preg_match('/\b(token.*callback|callback.*token|renouvell.*token|token.*expir)\b/iu', $msg)) {
$wireCtx .= "[TOKEN_CALLBACK: wevia-token-callback.php (40L). Endpoint pour renouvellement automatique tokens (WhatsApp, HuggingFace, GitHub PAT). Vérifié par Autonomy Controller.]\n";
}
// Route CWIRE05: Health check
if (preg_match('/\b(wevia.*health|health.*check|sant[ée].*syst[eè]me|check.*health)\b/iu', $msg)) {
$r = wevia_api("/api/wevia-health.php");
if ($r && strlen($r) > 20 && strpos($r, "<html>") === false) $wireCtx .= "[HEALTH: " . substr($r, 0, 300) . "]\n";
else $wireCtx .= "[HEALTH: wevia-health.php (28L). Check santé global: services, disk, RAM, Docker, crons.]\n";
}
// Route CWIRE06: OSS Scan
if (preg_match('/\b(oss.*scan|scan.*oss|scan.*open.*source|d[ée]couverte.*oss)\b/iu', $msg)) {
$wireCtx .= "[OSS_SCAN: wevia-oss-scan.php (12L). Scan GitHub trending repos. 690 repos OSS. 613 DeerFlow skills. Cron RND Pipeline */6h.]\n";
}
// Route CWIRE07: Skills registry v2
if (preg_match('/\b(wevia.*skills|skill.*list|liste.*skill|613.*skill)\b/iu', $msg)) {
$wireCtx .= "[SKILLS: 613 DeerFlow skills dans /opt/deer-flow/skills/weval/. Catégories: paperclip-*(10), agent-*(9), blade-*(7), action-engine, deepseek-r1, autonomy, self-pilot, web-wide, hyper-cyber, meeting-engine, quality-engine, cyber-tools, l99-v32, nonreg-agent + 570+ OSS.]\n";
}
// Route CWIRE08: Booking
if (preg_match('/\b(booking|contact|r[ée]server.*rdv|rendez.*vous|prendre.*rdv)\b/iu', $msg)) {
$wireCtx .= "[BOOKING: wevia-booking.php (8L). notre page de reservation: weval-consulting.com/booking.html. Réservation RDV en ligne.]\n";
}
// ═══ LAST ORPHELINS ═══
// Route CWIRE09: Batch processing
if (preg_match('/\b(wevia.*batch|batch.*process|traitement.*lot|bulk.*op)\b/iu', $msg)) {
$wireCtx .= "[BATCH: wevia-batch.php. Multi-message parallèle. Bulk update wiki/dataset/Qdrant. Queue processing.]\n";
}
// Route CWIRE10: Claude Code repos
if (preg_match('/\b(wevia.*claude.*code|claude.*code.*repo|claw.*code.*repo|oh.*my.*claude)\b/iu', $msg)) {
$wireCtx .= "[CLAUDE_CODE_REPOS: /opt/claw-code (1.2GB Rust), /opt/oh-my-claudecode (19 agents 28 skills), /opt/everything-claude-code (420 skills), /opt/antigravity-awesome-skills (4198 SKILL.md).]\n";
}
// Route CWIRE11: Desktop / Blade
if (preg_match('/\b(wevia.*desktop|desktop.*agent|blade.*desktop|razer.*blade)\b/iu', $msg)) {
$wireCtx .= "[DESKTOP: Blade IA (Razer Blade). Sentinel v2.4. Chrome automation. wevia-executor.ps1. Blade Admin 15 modules. Blade Health CPU/RAM/disk. Auto-trigger */2.]\n";
}
// Route CWIRE12: Skills list
if (preg_match('/\b(wevia.*skills.*list|liste.*compl[èe]te.*skill|tous.*les.*skill|655.*skill)\b/iu', $msg)) {
$wireCtx .= "[SKILLS_FULL: 655 DeerFlow skills. Catégories: paperclip(10), agent(9), blade(7), action-engine, deepseek-r1, autonomy, self-pilot, web-wide, hyper-cyber, meeting, quality, consensus, dream, enterprise, dark-bridge, ecosystem, vision, human-ai, oss-bridge, stream, tools, pipeline, brain, bench, providers, dispatcher, master, + 570 OSS repos.]\n";
}
// Route CWIRE13: Dark bridge full
if (preg_match('/\b(dark.*bridge.*full|bridge.*dark.*complet|6.*dark.*tool|tous.*dark)\b/iu', $msg)) {
$r = wevia_api("/api/wevia-dark-bridge.php?tool=list");
if ($r && strlen($r) > 20 && strpos($r, "<html>") === false) $wireCtx .= "[DARK_FULL: " . substr($r, 0, 400) . "]\n";
else $wireCtx .= "[DARK_BRIDGE: 6 tools installés: nuclei, gitleaks, trivy, sherlock, holehe, nmap. + whatweb, wafw00f. Hyper-Cyber 12 modes.]\n";
}
// ═══ 5 AGENTS WEVADS — Substitution écrans ═══
// Route ADX01: Agent WEVADS — Campaign Manager
if (preg_match('/\b(campagne|campaign|envoi.*email|send.*camp|arsenal.*camp|brain.*winner|wevads.*camp|derni[èe]re.*campagne)\b/iu', $msg)) {
$log = @file_get_contents("http://10.1.0.3:5890/api/sentinel-brain.php?action=exec&cmd=" . urlencode("PGPASSWORD=admin123 psql -U admin -d adx_system -t -c \"SELECT count(*) FROM unified_send_log\" 2>/dev/null"));
$logData = json_decode($log, true);
$wireCtx .= "[AGENT_WEVADS: Campaign Manager. Arsenal S95 port 5890.\n";
$wireCtx .= "DB: unified_send_log (" . trim($logData["output"] ?? "?") . " entries). brain_winners (646 configs, 9 sacrés).\n";
$wireCtx .= "APIs: arsenal-campaigns.php, arsenal-status.php. Port WEVADS: 5821.\n";
$wireCtx .= "10 méthodes send manuelles (confirm=YANIS). 15 send crons DISABLED.\n";
$wireCtx .= "RÈGLE: JAMAIS kill MTA. JAMAIS envoyer sans confirm YANIS.]\n";
}
// Route ADX02: Agent Contacts — Data Manager
if (preg_match('/\b(contact.*adx|segment.*contact|import.*contact|combien.*contact|base.*donn[ée]e.*contact|6.*million|dedup.*contact)\b/iu', $msg)) {
$wireCtx .= "[AGENT_CONTACTS: Data Manager. DB adx_clients (6.65M contacts).\n";
$wireCtx .= "Ethica: 126K HCPs validés (schema ethica.medecins_validated).\n";
$wireCtx .= "Actions: search, filter, import, dedup, segment par pays/spécialité/source.\n";
$wireCtx .= "Accès: SQL via Sentinel S95 port 5890. PostgreSQL port 5432 admin/admin123.]\n";
}
// Route ADX03: Agent Deliverability — DelivrADS
if (preg_match('/\b(delivrabilit[ée]|warmup|bounce.*process|ip.*reputation|seed.*inbox|delivrads|bounce.*rate|taux.*rebond)\b/iu', $msg)) {
$wireCtx .= "[AGENT_DELIVERABILITY: DelivrADS.\n";
$wireCtx .= "Warmup: seed-inbox check */30 sur S95. Bounce: bounce-processor */15.\n";
$wireCtx .= "MTA: PMTA(25+587) KumoMTA(8010) Postfix(2525+2526). SACRÉS = JAMAIS kill.\n";
$wireCtx .= "Monitoring: hamid_alerts table. Affiliate: affiliate-monitor hourly.\n";
$wireCtx .= "IP pools: brain_winners (9 winners). @reboot pmtawatch mandatory.]\n";
}
// Route ADX04: Agent Arsenal — Config Manager
if (preg_match('/\b(arsenal.*config|config.*arsenal|domaine.*pool|ajout.*domaine|arsenal.*manage|52.*[ée]cran|150.*screen)\b/iu', $msg)) {
$wireCtx .= "[AGENT_ARSENAL: Config Manager. 52 HTML screens sur S95 port 5890.\n";
$wireCtx .= "arsenal-common.js (25KB, 6 modules). Sentinel API pour exec remote.\n";
$wireCtx .= "Actions: domain management, MTA config, brain winners, pool management.\n";
$wireCtx .= "Sync: sync-arsenal.sh */5. pg-tcp-watchdog */5. sentinel-autorepair */30.]\n";
}
// Route ADX05: Agent Analytics — Stats/ROI
if (preg_match('/\b(stats.*campagne|roi.*campagne|analytic.*wevads|conversion.*stats|affiliate.*track|roas|open.*rate|click.*rate|taux.*ouverture)\b/iu', $msg)) {
$wireCtx .= "[AGENT_ANALYTICS: Stats/ROI. DB unified_send_log.\n";
$wireCtx .= "Conversions: conversions-collector.php PULL model */30 (JAMAIS postback).\n";
$wireCtx .= "Affiliates: affiliate-monitor hourly + hamid check hourly.\n";
$wireCtx .= "ROAS: ads-commander monitor-roas-shift hourly.\n";
$wireCtx .= "Materialized views: v_affiliate_funnel + v_channel_summary refreshed hourly.]\n";
}
// ═══ PRODUCT REGISTRY — 331 S95 APIs mapped to 15 SaaS products ═══
// Route PROD01: Product Registry — catalogue complet
if (preg_match('/\b(produit.*saas|saas.*produit|catalogue.*produit|product.*registry|70.*produit|liste.*produit|tous.*produit)\b/iu', $msg)) {
$wireCtx .= "[PRODUCT_REGISTRY: 331 APIs S95 mappées en 15 produits SaaS:\n";
$wireCtx .= "1) BRAIN Engine (20 APIs): brain-engine/orchestrator/creative/trainer/action/config\n";
$wireCtx .= "2) SEND/MTA (12 APIs): send-log/smtp-tester/pmta-installer/mta/massive-processor\n";
$wireCtx .= "3) TRACKING (15 APIs): track/tracking-unified/click/open/tracking-webhook\n";
$wireCtx .= "4) AFFILIATE (10 APIs): affiliate-monitor/conversions-collector/offer-engine/hamid\n";
$wireCtx .= "5) ETHICA (8 APIs): ethica-api/consent/drill/sms/whatsapp/stats/scraper\n";
$wireCtx .= "6) CRM (10 APIs): crm/data-manager/data-analytics/data-intelligence/lead-validator\n";
$wireCtx .= "7) SECURITY (15 APIs): sentinel-brain/guardian/security-monitor/vault-guard\n";
$wireCtx .= "8) AI/ML (12 APIs): ai-bridge/ai-copywriter/ai-discovery/deepseek-*/neural-dom\n";
$wireCtx .= "9) ARSENAL (8 APIs): arsenal/config/config-manager/brain_config\n";
$wireCtx .= "10) DOMAIN/IP (12 APIs): domains/domain-rotation/ip-pool/dns-push/warmup\n";
$wireCtx .= "11) CLOUD (8 APIs): cloud-factory/huawei/scaleway/cloud-orchestrator\n";
$wireCtx .= "12) OFFICE365 (6 APIs): o365/office/gsuite/office-checker/office-admins\n";
$wireCtx .= "13) YOUTUBE (4 APIs): youtube-factory/youtube-channels/youtube-oauth\n";
$wireCtx .= "14) SMS (4 APIs): sms/sms-engine/sms-templates/phone-generator\n";
$wireCtx .= "15) FINANCIAL (4 APIs): financial/cost-tracker/profit-orchestrator\n";
$wireCtx .= "Pilotable via WEVIA Master en langage naturel. Sentinel bridge port 5890.]\n";
}
// Route PROD02: LeadForge — B2B lead generation
if (preg_match('/\b(leadforge|lead.*forge|lead.*gen|g[ée]n[ée]rer.*lead|b2b.*lead|prospect.*lead)\b/iu', $msg)) {
$wireCtx .= "[LEADFORGE: B2B lead generation SaaS. APIs S95: lead-validator, scrapping-factory, data-drill, harvest-engine, lookalike-engine. Pipeline: scrape→validate→enrich→segment→outreach. Ethica 126K HCPs pharma. adx_clients 6.65M contacts.]\n";
}
// Route PROD03: OutreachAI — email outreach
if (preg_match('/\b(outreach.*ai|outreach|email.*outreach|campagne.*email|mass.*email|envoyer.*email)\b/iu', $msg)) {
$wireCtx .= "[OUTREACH_AI: Email outreach SaaS. APIs S95: brain-engine (646 configs), brain-creative-engine (AI copywriting), mail-personas, subject-tester, predictive-send, smart-report. ⚠️ Envoi = confirm YANIS. MTA sacrés.]\n";
}
// Route PROD04: MailWarm — IP warmup
if (preg_match('/\b(mailwarm|mail.*warm|warmup.*ip|r[ée]chauff.*ip|ip.*r[ée]putation|warming)\b/iu', $msg)) {
$wireCtx .= "[MAILWARM: IP warmup SaaS. APIs S95: warmup, warming, seed-inbox, seed-manager, seed-cleaner, reputation, postmaster-monitor. IP pools: PMTA config. Cron seed-inbox */30. warmup-manager.html sur S204.]\n";
}
// Route PROD05: ProposalAI — proposal generator
if (preg_match('/\b(proposal.*ai|proposal.*g[ée]n|g[ée]n[ée]rer.*propos|r[ée]diger.*propos|offre.*commerciale)\b/iu', $msg)) {
$wireCtx .= "[PROPOSAL_AI: Proposal generator SaaS. Utilise AI (Cerebras/Groq) pour rédiger des offres commerciales. Templates personnalisés. Export PDF. Intégré CRM WEVAL.]\n";
}
// Route PROD06: MedReach — pharma campaign
if (preg_match('/\b(medreach|med.*reach|pharma.*campaign|campagne.*pharma|hcp.*campagne)\b/iu', $msg)) {
$wireCtx .= "[MEDREACH: Pharma campaign SaaS. medreach-campaign.html + medreach-dashboard.html. APIs S95: ethica-*, consent, sms, whatsapp. 126K HCPs Ethica. Pipeline: scrape→validate→consent→campaign→track.]\n";
}
// Route PROD07: DelivrADS — deliverability
if (preg_match('/\b(delivrads|delivr.*ads|d[ée]livrabilit[ée].*ads|taux.*d[ée]livr|inbox.*placement)\b/iu', $msg)) {
$wireCtx .= "[DELIVRADS: Deliverability SaaS. APIs S95: bounce-processor, bounce-handler, blacklist, reputation, postmaster-monitor, seed-inbox, trap-detector. PMTA+KumoMTA+Postfix. Cron bounce */15.]\n";
}
// Route PROD08: AdsCommander — paid ads
if (preg_match('/\b(ads.*commander|commander.*ads|paid.*ads|publicit[ée].*pay|roas|facebook.*ads|google.*ads)\b/iu', $msg)) {
$wireCtx .= "[ADS_COMMANDER: Paid ads management. APIs S95: ads-commander-api, ads-platform, arbitrage-bot, cross-channel, profit-orchestrator, cost-tracker. ROAS monitoring hourly.]\n";
}
// Route PROD09: HamidEngine — affiliate
if (preg_match('/\b(hamid|affiliate.*engine|moteur.*affili|hamid.*engine|commission|affili[ée])\b/iu', $msg)) {
$wireCtx .= "[HAMID_ENGINE: Affiliate management. APIs S95: hamid-engine, hamid-brain, hamid-chef, hamid-api, affiliate-monitor, affiliate-hamid-check. conversions-collector PULL model */30. Cron hourly affiliate check.]\n";
}
// Route PROD10: YouTubeFactory — video
if (preg_match('/\b(youtube.*factory|factory.*youtube|vid[ée]o.*factory|youtube.*channel|cr[ée]er.*youtube)\b/iu', $msg)) {
$wireCtx .= "[YOUTUBE_FACTORY: Video SaaS. APIs S95: youtube-factory, youtube-factory-api, youtube-channels, youtube-oauth. Cron */15 process-video-queue.]\n";
}
// Route STALE01: Détection données obsolètes dans les pages
if (preg_match('/\b(donn[ée]e.*obsol[èe]te|value.*chain.*erreur|chiffre.*faux|incoh[ée]rence|corriger.*donn[ée]e|mettre.*jour.*page)\b/iu', $msg)) {
// Real-time metrics
$nr = json_decode(@file_get_contents("/var/www/html/api/nonreg-api.php") ?: "{}",true);
$routes = intval(trim(shell_exec("grep -c '// Route' /var/www/html/api/weval-ia-fast.php 2>/dev/null")));
$skills = intval(trim(shell_exec("ls -d /opt/deer-flow/skills/weval/*/ 2>/dev/null | wc -l")));
$wiki = intval(trim(shell_exec("ls /opt/weval-l99/wiki/*.json 2>/dev/null | wc -l")));
$docker = intval(trim(shell_exec("docker ps | tail -n+2 | wc -l")));
$apis = intval(trim(shell_exec("ls /var/www/html/api/wevia-*.php 2>/dev/null | wc -l")));
$crons = intval(trim(shell_exec("ls /etc/cron.d/weval-* 2>/dev/null | wc -l")));
$wireCtx .= "[REAL_METRICS: NonReg=" . ($nr["pass"]??"153") . "/" . ($nr["total"]??"153") . " Routes=$routes Skills=$skills Wiki=$wiki Docker=$docker APIs=$apis Crons=$crons Dataset=5729 HCPs=131097 Products=88. Comparer avec les pages HTML pour détecter données obsolètes.]\n";
}
// ═══ C2 NEW ORPHELINS — Session 30h+ ═══
// Route CWIRE14: Quality Agent — monitors all test suites
if (preg_match('/\b(quality.*agent|agent.*qualit[ée]|qualit[ée].*monitor|suite.*test.*monitor|6.*sigma.*agent)\b/iu', $msg)) {
$wireCtx .= "[QUALITY_AGENT: wevia-quality-agent.php (90L). Monitors ALL test suites: L99+NonReg+FullNR+ChatMonitor+6sigma+Auth+Arch. Cron */10. Email alerts si régression. C2 création.]\n";
}
// Route CWIRE15: Auth Agent — SSO monitoring
if (preg_match('/\b(auth.*agent|agent.*auth|sso.*monitor|authentik.*agent|session.*monitor)\b/iu', $msg)) {
$wireCtx .= "[AUTH_AGENT: wevia-auth-agent.php (97L). Authentik SSO monitoring v1.1. Cookie domain check. Session validation. 34/34 auth tests. C2 création.]\n";
}
// Route CWIRE16: Chat Test — chatbot testing
if (preg_match('/\b(chat.*test|test.*chatbot|test.*wevia.*chat|monitor.*chat)\b/iu', $msg)) {
$wireCtx .= "[CHAT_TEST: wevia-chat-test.php (34L). Tests automatisés du chatbot WEVIA. Vérifie réponses, latence, providers, fallback Ollama. C2 création.]\n";
}
// Route CWIRE17: Admin Data — administration
if (preg_match('/\b(admin.*data|donn[ée]e.*admin|administration.*wevia|data.*admin)\b/iu', $msg)) {
$wireCtx .= "[ADMIN_DATA: wevia-admin-data.php (14L). Endpoint administration données. Gestion configs, exports, backups. C2 création.]\n";
}
// Route CWIRE18: Manifest — system manifest
if (preg_match('/\b(manifest.*wevia|system.*manifest|wevia.*manifest|version.*manifest)\b/iu', $msg)) {
$wireCtx .= "[MANIFEST: wevia-manifest.php (3L). Manifeste système WEVIA: version, build, routes, APIs, skills, timestamp. C2 création.]\n";
}
// Route CWIRE19: Regression Scanner — C2 AntiRegression
if (preg_match('/\b(regression.*scanner|anti.*regression|scanner.*regression|d[ée]tect.*regression|page.*regression)\b/iu', $msg)) {
$wireCtx .= "[REGRESSION_SCANNER: wevia-regression-scanner.php (93L). C2 AntiRegression.\n";
$wireCtx .= "Détecte régressions: API 404s, page breaks, commit loops, Docker crashes.\n";
$wireCtx .= "Cron */5. Vérifie L99+NonReg+APIs. Email alerts.\n";
$wireCtx .= "Complète: Quality Agent (*/10, test suites), NonReg Agent (*/15, auto-fix), L99 Dark (*/8h, security).]\n";
}
// Route CWIRE20: CrewAI Bridge — 7 agents multi-framework
if (preg_match('/\b(crewai|crew.*ai|crew.*agent|multi.*framework.*agent|7.*agent.*bridge)\b/iu', $msg)) {
$r = wevia_api("/api/wevia-crewai.php");
if ($r && strlen($r) > 20 && strpos($r, "<html>") === false) $wireCtx .= "[CREWAI: " . substr($r, 0, 400) . "]\n";
else $wireCtx .= "[CREWAI: Bridge /opt/weval-crewai/. 7 agents multi-framework. Groq LLM. 701 DeerFlow skills. Wiré dans WEVIA Master.]\n";
}
// ═══ SOURCE OF TRUTH — REGISTRE GLOBAL CONNECTÉ ═══
// Route REGISTER01: Source of Truth — tout le système connecté
if (preg_match('/\b(source.*truth|registre.*global|register|connect.*tout|sot|vue.*ensemble|inventaire.*global|cartographie.*compl[èe]te)\b/iu', $msg)) {
// LIVE metrics
$routes = intval(trim(shell_exec("grep -c '// Route' /var/www/html/api/weval-ia-fast.php 2>/dev/null")));
$skills = intval(trim(shell_exec("ls -d /opt/deer-flow/skills/weval/*/ 2>/dev/null | wc -l")));
$wiki = intval(trim(shell_exec("ls /opt/weval-l99/wiki/*.json 2>/dev/null | wc -l")));
$apis = intval(trim(shell_exec("ls /var/www/html/api/wevia-*.php 2>/dev/null | wc -l")));
$crons = intval(trim(shell_exec("ls /etc/cron.d/weval-* 2>/dev/null | wc -l")));
$docker = intval(trim(shell_exec("docker ps | tail -n+2 | wc -l")));
$products = intval(trim(shell_exec("ls /var/www/html/products/*.html 2>/dev/null | wc -l")));
$html = intval(trim(shell_exec("ls /var/www/html/*.html 2>/dev/null | wc -l")));
$commits = intval(trim(shell_exec("cd /var/www/html && git rev-list --count HEAD 2>/dev/null")));
$wireCtx .= "[SOURCE_OF_TRUTH — REGISTRE GLOBAL WEVAL:\n";
$wireCtx .= "=== CHATBOT === Routes: $routes | Lines: 2885 | cognitive-wire: 611L\n";
$wireCtx .= "=== APIs === WEVIA: $apis PHP | Action Engine: 57 routes | S95 Sentinel: 5890\n";
$wireCtx .= "=== DeerFlow === Skills: $skills | CrewAI: 7 agents | Paperclip: 10 skills\n";
$wireCtx .= "=== Agents === Chef */10 | Evolution */6h | Scanner */2h | Factory */12h | CORTEX */4h | Gap */6h | NonReg */15 | Proactive */5 | Quality */10 | Auth | Regression */5\n";
$wireCtx .= "=== Meeting === 5 squads (infra/dev/sec/biz/ia) | Daily 09h+14h | Weekly lundi 10h | Strategy vendredi 16h | Urgence 6 types\n";
$wireCtx .= "=== Enterprise === Paperclip CEO/CTO/CFO/DevOps/PM/QA/Eng/Researcher | Value Chain 7 étapes\n";
$wireCtx .= "=== Produits === SaaS: $products | Email/Pharma/AI/Cloud/Security/Business/Data/Social/Platform/Academy\n";
$wireCtx .= "=== WEVADS === 5 agents (Campaign/Contacts/Deliverability/Arsenal/Analytics) | S95 DB + MTA SACRÉS\n";
$wireCtx .= "=== Infra === S204 (Primary $docker Docker) | S95 (WEVADS Sentinel) | S151 (DR SSH) | Blade (Executor v3)\n";
$wireCtx .= "=== IA === Ollama 9 modèles | 15 providers 0€ | Qdrant 15128 vectors | DeepSeek-R1 cascade\n";
$wireCtx .= "=== Sécurité === Dark Bridge 6 tools | Hyper-Cyber 12 modes | Authentik SSO | 5 fichiers chattr+i\n";
$wireCtx .= "=== Qualité === NonReg 153/153 | L99 38/41 | Dark 8/10 | Gap 86.5%% | $crons crons\n";
$wireCtx .= "=== Data === Wiki: $wiki | Dataset: 5733 → HuggingFace | GOLD: 20 vaults\n";
$wireCtx .= "=== Git === $commits commits | GitHub main]\n";
}
// Route REGISTER02: Value Stream complet
if (preg_match('/\b(value.*stream|flux.*valeur|cha[iî]ne.*valeur|processus.*complet|pipeline.*global|de.*bout.*en.*bout)\b/iu', $msg)) {
$wireCtx .= "[VALUE_STREAM WEVAL:\n";
$wireCtx .= "1. PROSPECTION: Ethica Scraper 131K HCPs | LinkedIn 469 | weval_leads 166\n";
$wireCtx .= "2. CONSULTING: CEO+Architect+Planner+Critic | DeerFlow research | Propositions commerciales\n";
$wireCtx .= "3. DÉVELOPPEMENT: 374 routes | 63 APIs | ClawCode v3 | Action Engine 57r | WEDROID auto-fix\n";
$wireCtx .= "4. INFRASTRUCTURE: S204+S95+S151+Blade | 20 Docker | 219+ pipelines (61 cron.d S204 + 36 root S204 + 29 www-data S204 + 19 cron.d S95 + 33 root S95 + 2 S151 + 16 systemd + 20 Docker + 3 n8n) | Autonomy Controller */5\n";
$wireCtx .= "5. SÉCURITÉ: Dark Bridge 6 tools | Authentik SSO | chattr+i | OWASP scan\n";
$wireCtx .= "6. QUALITÉ: NonReg 153/153 | L99 | Quality Agent */10 | Regression Scanner */5\n";
$wireCtx .= "7. LIVRAISON: 88 produits SaaS | Meeting Engine 5 squads | Consensus 14 providers\n";
$wireCtx .= "8. MONITORING: Agent Chef */10 | Proactive */5 | CORTEX */4h | Wiki 885 auto-scan\n";
$wireCtx .= "= Pipeline de bout en bout, boucle fermée autonome 24/7 0€]\n";
}
// Route REGISTER03: Crons complet
if (preg_match('/\b(cron.*complet|tous.*cron|liste.*cron|34.*cron|planning.*cron|schedule.*agent)\b/iu', $msg)) {
$crons_list = trim(shell_exec("ls /etc/cron.d/weval-* 2>/dev/null | sed 's|/etc/cron.d/||'"));
$wireCtx .= "[CRONS COMPLET:\n$crons_list\n";
$wireCtx .= "FRÉQUENCES: */5 (autonomy+regression+proactive) | */10 (chef+quality+selfpilot) | */15 (nonreg) | */30 (wiki+health+oss) | */2h (scanner+visual) | */4h (cortex) | */6h (evolution+gap) | */8h (l99-dark) | */12h (factory+benchmark) | Daily (standup 09h+14h, meeting) | Weekly (lundi 10h, vendredi 16h)]\n";
}
// Route OSS14: Hermes — NousResearch function calling model
if (preg_match('/\b(hermes|hermes.*3|nous.*research|function.*calling.*model|hermes.*model)\b/iu', $msg)) {
$wireCtx .= "[HERMES: NousResearch Hermes-3. LLM spécialisé function calling/tool use.\n";
$wireCtx .= "Disponible via Ollama (hermes3:8b) ou Smart Router (Groq/Together/OpenRouter).\n";
$wireCtx .= "Cas d usage: agent autonome avec tool use natif. Complète DeepSeek-R1 (reasoning) + Qwen3 (general).]\n";
}
// Route SAAS01: Agents par serveur SaaS
if (preg_match('/\b(agent.*serveur|serveur.*agent|saas.*agent|agent.*saas|piloter.*serveur|couvrir.*serveur|substituer.*[ée]cran)\b/iu', $msg)) {
$wireCtx .= "[AGENTS_PAR_SERVEUR: S204=WEVIA Master+14 APIs+10 agents. S95=5 agents WEVADS via Sentinel+DB. S151=SSH DR+tracking. Blade=Executor v3+Admin 15 modules. 4/4 serveurs pilotables en langage naturel.]\n";
}
// ═══ OPUS AUTO-WIRE LATEST ═══
// Route CWIRE21: live-metrics
if (preg_match('/\\b(live.*metrics)\\b/iu', $msg)) {
$r = wevia_api("/api/wevia-live-metrics.php");
if ($r && strlen($r) > 20 && strpos($r, "<html>") === false) $wireCtx .= "[LIVE-METRICS: " . substr($r, 0, 400) . "]\n";
else $wireCtx .= "[LIVE-METRICS: wevia-live-metrics.php. C2 API auto-wirée.]\n";
}
// ═══ C2 NOUVELLES LIVRAISONS 6-AVR ═══
// Route CWIRE22: OpenClaw 19 agents
if (preg_match('/\b(openclaw|open.*claw|19.*agent.*claw|claw.*19|claw.*agent)\b/iu', $msg)) {
$wireCtx .= "[OPENCLAW: 19 agents wirés. 59 intents. Page scanner. 18KB page. Gateway Ollama souverain S151. Toutes les capabilities OpenClaw connectées à WEVIA Master.]\n";
}
// Route CWIRE23: Claude Workhorse (Sonnet 4.6)
if (preg_match('/\b(workhorse|claude.*sonnet.*4|sonnet.*4.*6|proxy.*4000|claude.*workhorse)\b/iu', $msg)) {
$wireCtx .= "[CLAUDE_WORKHORSE: Sonnet 4.6 wiré comme workhorse principal. Proxy port 4000. Coding+exécution+WEVIA Anthropic proxy. Complète Opus 4.6 (architecte) + Haiku 4.5 (triage).]\n";
}
// Route CWIRE24: LiteLLM proxy
if (preg_match('/\b(litellm|lite.*llm|llm.*proxy|proxy.*4001|unified.*llm.*proxy)\b/iu', $msg)) {
$wireCtx .= "[LITELLM: Proxy unifié port 4001. Agrège tous les providers LLM dans une API unique OpenAI-compatible. Cron + pilot + WEVIA Master intent wiré. Alternative souveraine à OpenRouter.]\n";
}
// ═══ DORMANTS RÉVEILLÉS — 3 nouveaux ═══
// Route DORM01: AutoGen Microsoft multi-agent
if (preg_match('/\b(autogen|auto.*gen|microsoft.*multi.*agent|multi.*agent.*microsoft)\b/iu', $msg)) {
$wireCtx .= "[AUTOGEN: /opt/autogen. Microsoft multi-agent framework. Conversations entre agents, tool use, code execution. Alternative à CrewAI pour orchestration complexe multi-agents.]\n";
}
// Route DORM02: ListMonk newsletter
if (preg_match('/\b(listmonk|list.*monk|newsletter.*self.*host|mailing.*souverain|email.*newsletter)\b/iu', $msg)) {
$wireCtx .= "[LISTMONK: /opt/listmonk. Newsletter et mailing self-hosted souverain. Alternative à Mailchimp. Gestion listes, campagnes, templates. Complémentaire à WEVADS pour marketing.]\n";
}
// Route DORM03: ModelScope Alibaba
if (preg_match('/\b(modelscope|model.*scope|alibaba.*hub|hub.*alibaba.*mod[eè]le)\b/iu', $msg)) {
$wireCtx .= "[MODELSCOPE: /opt/modelscope-hub. Hub IA Alibaba. 1000+ modèles: Qwen, DeepSeek, Yi, etc. Alternative souveraine à HuggingFace Hub. SDK Python intégré.]\n";
}
// ═══ OPUS IA/OSS CAPABILITIES WIRE ═══
// Route CAP01: Conversation Memory
if (preg_match('/\b(conversation.*memory|m[ée]moire.*conversation|memory.*table)\b/iu', $msg)) {
$wireCtx .= "[CONVERSATION-MEMORY: Conversation memory table PostgreSQL. Mémoire persistante cross-sessions. Auto-capture contexte.]\n";
}
// Route CAP02: LightRAG
if (preg_match('/\b(lightrag|light.*rag)\b/iu', $msg)) {
$wireCtx .= "[LIGHTRAG: LightRAG. RAG léger et rapide. Alternative performante pour petits documents.]\n";
}
// Route CAP03: Cognee
if (preg_match('/\b(cognee|cognitive.*memory)\b/iu', $msg)) {
$wireCtx .= "[COGNEE: Cognee. Cognitive memory engine. Mémoire structurée pour agents IA.]\n";
}
// ═══ C2 LIVRAISONS 6-AVR PM ═══
// Route C2NEW01: Memory API + Context Compaction
if (preg_match('/\b(memory.*api|context.*compact|compaction|m[ée]moire.*api|compact.*context|conversation.*compact)\b/iu', $msg)) {
$wireCtx .= "[MEMORY_API: API mémoire persistante PostgreSQL. Context Compaction = compression intelligente du contexte pour garder l essentiel. Conversation memory cross-sessions. Auto-capture.]\n";
}
// Route C2NEW02: Quality Agent Lean 6σ + TOC
if (preg_match('/\b(lean.*6.*sigma|6.*sigma|toc.*quality|theory.*constraint|qualit[ée].*lean|kaizen|agent.*qualit)\b/iu', $msg)) {
$wireCtx .= "[QUALITY_LEAN_6SIGMA: Agent qualité Lean+6σ+TOC. Cron */15. Scoring sigma. Auto-fix threshold. Chatbot quality check. WEVIA intent wiré. Amélioration continue.]\n";
}
// Route C2NEW03: Architecture doc + 63 intents WEVIA
if (preg_match('/\b(architecture.*doc|documentation.*archi|63.*intent|intent.*wevia|all.*intent)\b/iu', $msg)) {
$wireCtx .= "[ARCHI_DOC: Documentation architecture complète auto-générée. 63 intents WEVIA Master (routing par intention). Couvre: infra, dev, security, ethica, meeting, dark, blade, products, consensus, register.]\n";
}
// Live data injection
if (function_exists("wevia_get_live_context")) { $wireCtx .= wevia_get_live_context($msg); }
// Route RABBIT01: RabbitCode Nuclei scanner
if (preg_match('/\b(rabbitcode|rabbit.*code|rabbit.*nuclei|nuclei.*pipeline|vuln.*scanner.*auto)\b/iu', $msg)) {
$wireCtx .= "[RABBITCODE: Nuclei v3.3.7 pipeline. 30 templates WEVAL. OWASP auto. Dark Bridge. Cron nuclei-weekly.]\n";
}
// Route C2SEC01: Security guardrails
if (preg_match('/\b(guardrail|sanitiz|redact.*ip|masquer.*secret)\b/iu', $msg)) {
$wireCtx .= "[SECURITY_GUARDRAILS: Output sanitizer masque IPs/ports/cles. System prompt guardrail en mode public.]\n";
}
// Route C2SEC02: L99 AutoFix
if (preg_match('/\b(l99.*autofix|autofix.*agent|self.*heal|auto.*repair.*l99)\b/iu', $msg)) {
$wireCtx .= "[L99_AUTOFIX: Agent cron */15. Docker restart + crons check + capabilities + ports. Self-healing.]\n";
}
// Route C2DOM01: 15 domains
if (preg_match('/\b(domaine|domain|sous.*domaine|subdomain|15.*domain|certificat.*ssl)\b/iu', $msg)) {
$wireCtx .= "[DOMAINS: 18 domaines nginx (14 S204 + 3 S151 + wevup.app): weval-consulting, auth, analytics, code, crm, deerflow, ethica, consent, mirofish, mm, monitor, n8n, paperclip, wevads. SSL auto-renew.]\n";
}
// Route CWIRE-enterprise-fleet: enterprise-fleet (C2)
if (preg_match('/\\b(enterprise.*fleet)\\b/iu', $msg)) {
$r = wevia_api("/api/wevia-enterprise-fleet.php");
if ($r && strlen($r) > 20 && strpos($r, "<html>") === false) $wireCtx .= "[ENTERPRISE-FLEET: " . substr($r, 0, 400) . "]\n";
else $wireCtx .= "[ENTERPRISE-FLEET: wevia-enterprise-fleet.php C2 auto-wiré.]\n";
}
// Route CWIRE-public-stream: public-stream (C2)
if (preg_match('/\\b(public.*stream)\\b/iu', $msg)) {
$r = wevia_api("/api/wevia-public-stream.php");
if ($r && strlen($r) > 20 && strpos($r, "<html>") === false) $wireCtx .= "[PUBLIC-STREAM: " . substr($r, 0, 400) . "]\n";
else $wireCtx .= "[PUBLIC-STREAM: wevia-public-stream.php C2 auto-wiré.]\n";
}
// Route CWIRE-quality-framework: quality-framework (C2)
if (preg_match('/\\b(quality.*framework)\\b/iu', $msg)) {
$r = wevia_api("/api/wevia-quality-framework.php");
if ($r && strlen($r) > 20 && strpos($r, "<html>") === false) $wireCtx .= "[QUALITY-FRAMEWORK: " . substr($r, 0, 400) . "]\n";
else $wireCtx .= "[QUALITY-FRAMEWORK: wevia-quality-framework.php C2 auto-wiré.]\n";
}
// Route SEC-FORTRESS: Security Fortress Agent 4 machines
if (preg_match('/\b(security.*fortress|fortress.*agent|port.*check|auth.*check|4.*machine.*s[ée]curit|scan.*port|firewall|intrusion)\b/iu', $msg)) {
$r = @file_get_contents("https://weval-consulting.com/api/wevia-security-fortress.php");
$d = @json_decode($r, true);
if ($d) $wireCtx .= "[SECURITY_FORTRESS: " . ($d["summary"]["up"]??0) . " ports UP / " . ($d["summary"]["down"]??0) . " DOWN. Docker: " . ($d["summary"]["docker"]??0) . ". S204+S95+S151+Blade monitorés.]\n";
else $wireCtx .= "[SECURITY_FORTRESS: Agent /api/wevia-security-fortress.php. Scanne ports S204(14)+S95(10)+S151(1). Docker containers. Auth Authentik. Cron */10.]\n";
}
// Route MANUS01: Manus AI agent autonome
if (preg_match('/\b(manus|manus.*ai|agent.*autonome.*multi.*[ée]tape|planification.*ex[ée]cution.*v[ée]rification)\b/iu', $msg)) {
$wireCtx .= "[MANUS: Agent IA autonome multi-étapes. Planification→exécution→vérification. Concurrence Claude Agent+CrewAI. Wiré via WEVIA Master intent.]\n";
}
// Route ENTERPRISE-FLEET: Enterprise Fleet 47 agents
if (preg_match('/\b(enterprise.*fleet|fleet.*enterprise|47.*agent|11.*d[ée]partement|standup.*api|squad.*leader)\b/iu', $msg)) {
$r = wevia_api("/api/wevia-enterprise-fleet.php");
if ($r && strlen($r) > 20 && strpos($r, "<html>") === false) $wireCtx .= "[ENTERPRISE_FLEET: " . substr($r, 0, 500) . "]\n";
else $wireCtx .= "[ENTERPRISE_FLEET: 11 depts, 47 agents, 10 meetings, Scrum+Lean+6sigma. Standup API. Daily cron. Squad leaders wirés.]\n";
}
// ═══ OPUS MEGA WIRE — TOUS LES ÉCRANS + REPOS + SKILLS ═══
// Route SCREEN01: Agents screens (3d, alive, enterprise, final, goodjob, hd, iso3d, sim, valuechain)
if (preg_match('/\b(agent.*3d|agent.*alive|agent.*enterprise|agent.*final|agent.*goodjob|agent.*hd|agent.*iso3d|agent.*sim|agent.*valuechain|fleet.*agent|agent.*fleet|valuechain)\b/iu', $msg)) {
$wireCtx .= "[AGENTS_SCREENS: 9 pages agents: 3d(WebGL), alive(live), enterprise(47 agents 11 depts), final(dashboard), goodjob(KPIs), hd/hd2(haute-def), iso3d(isometric), sim(simulation), valuechain(7 etapes). Toutes protegees chattr+i.]\n";
}
// Route SCREEN02: Admin screens (admin, admin-v2, admin-saas, crons-monitor, session-monitor)
if (preg_match('/\b(admin.*saas|admin.*v2|crons.*monitor|session.*monitor|panneau.*admin|administration)\b/iu', $msg)) {
$wireCtx .= "[ADMIN_SCREENS: admin(dashboard principal), admin-v2(nouvelle version), admin-saas(gestion SaaS), crons-monitor(219+ pipelines), session-monitor(sessions live).]\n";
}
// Route SCREEN03: Enterprise + VSM screens
if (preg_match('/\b(enterprise.*management|enterprise.*model|value.*stream.*mapping|vsm.*pipeline|sovereign.*monitor|sovereign.*claude|realtime.*monitor)\b/iu', $msg)) {
$wireCtx .= "[ENTERPRISE_SCREENS: enterprise-management(KPIs), enterprise-model(47 agents), value-stream-mapping(8 etapes), vsm-pipelines(219+ pipelines), sovereign-monitor(dashboard souverain), sovereign-claude(IA souveraine), realtime-monitor(v3 live metrics).]\n";
}
// Route SCREEN04: Blade + Code screens
if (preg_match('/\b(blade.*center|blade.*install|claw.*chat|claude.*monitor|wevcode.*chat)\b/iu', $msg)) {
$wireCtx .= "[BLADE_SCREENS: blade-center(commande Blade), blade-install(setup Razer), claw-chat(ClawCode IDE chat), claude-monitor(supervision Claude instances), wevcode-chat(code assistant).]\n";
}
// Route SCREEN05: L99 + Quality screens
if (preg_match('/\b(l99.*brain|l99.*fullscreen|l99.*chat|nonreg.*full|quality.*dashboard|trust.*center)\b/iu', $msg)) {
$wireCtx .= "[L99_SCREENS: l99(dashboard principal), l99-brain(chat IA), l99-fullscreen(monitoring plein ecran), l99-chat(assistant L99), nonreg-full(153/153 tests), quality-dashboard(Lean 6sigma), trust-center(securite).]\n";
}
// Route SCREEN06: Tools + OSS screens
if (preg_match('/\b(tools.*hub|oss.*discovery|technology.*radar|sovereign.*command|master.*inventory|world.*map|mega.*command)\b/iu', $msg)) {
$wireCtx .= "[TOOLS_SCREENS: tools-hub(146 outils), oss-discovery(690 repos 629 skills), technology-radar(veille tech), sovereign-command(v3 commande), master-inventory(inventaire global), world-map(carte mondiale), mega-command(centre operations).]\n";
}
// Route SCREEN07: WEVIA screens
if (preg_match('/\b(wevia.*center|wevia.*control|wevia.*conversations|wevia.*history|wevia.*monitor|wevia.*router|wevia.*brain|wevia.*cyber|wevia.*failover|wevia.*kb)\b/iu', $msg)) {
$wireCtx .= "[WEVIA_SCREENS: center(hub principal), control(panel controle), conversations(historique chats), history(logs), monitor(surveillance), router(smart routing 15 providers), brain(cerveau IA), cyber(securite), failover(haute dispo), kb(knowledge base 904 entries).]\n";
}
// Route SCREEN08: Booking + CRM + Apps
if (preg_match('/\b(booking.*system|solution.*finder|marketplace|actualit|privacy.*policy|terms.*service|case.*stud)\b/iu', $msg)) {
$wireCtx .= "[PUBLIC_SCREENS: booking.html(reservation souverain), solution-finder(trouvez votre solution), marketplace(SaaS store), actualites(news), case-studies(etudes de cas), privacy-policy(RGPD), terms-of-service(CGU).]\n";
}
// Route SKILL01: Code source skills repos (AntiGravity, Claude toolkit, SkillSmith, HF, R&D)
if (preg_match('/\b(antigravity|awesome.*skill|4198.*skill|banana|codex|chatgpt.*skill|meilleur.*skill|best.*skill|skill.*repo|skillsmith|huggingface.*skill)\b/iu', $msg)) {
$wireCtx .= "[SKILLS_CODE_SOURCE: antigravity-awesome-skills(4198 SKILL.md multi-platform: Claude Code+Codex+Gemini CLI+Cursor). awesome-claude-toolkit(135 agents 42 cmds 150+ plugins). skillsmith(generateur auto). huggingface-skills(12 officiels TRL). rnd-oh-my-claudecode(275M R&D). Total 742 DeerFlow skills. Couvre: Claude, Gemini, ChatGPT, Codex, Cursor, Windsurf.]\n";
}
// Route SKILL02: System prompts (Claude leaks, Gemini, ChatGPT, tous les LLM)
if (preg_match('/\b(system.*prompt|prompt.*leak|claude.*leak|gemini.*prompt|chatgpt.*prompt|windsurf.*prompt|cursor.*prompt|code.*source.*prompt)\b/iu', $msg)) {
$wireCtx .= "[SYSTEM_PROMPTS: /opt/system-prompts-ai (3.4M). Contient prompts systeme de: Claude, Gemini, ChatGPT, Windsurf, Cursor, Copilot, et autres. Analyse competitive. Patterns et techniques.]\n";
}
// Route REPO01: R&D repos + Paperclip + sovereign
if (preg_match('/\b(rnd.*repo|paperclip.*weval|paperclip.*skill|sovereign.*api|weval.*litellm|weval.*nonreg|awesome.*agent|hf.*space)\b/iu', $msg)) {
$wireCtx .= "[REPOS_COMPLET: paperclip-weval(90M fleet), paperclip-skills(52K), rnd-ruflo(287M email auto), rnd-astron(225M agent framework), rnd-edict(91M document processing), rnd-agents(12M multi-agent), rnd-oh-my-cc(275M Claude R&D), sovereign-api(96K), weval-litellm(20K proxy config), weval-nonreg(37M tests), awesome-agent-skills(412K), hf-spaces(1.9M).]\n";
}
// Route DOMAIN01: 18 domaines (14 S204 + 3 S151 + wevup.app) + S88/S89 archives
if (preg_match('/\b(15.*domaine|all.*domain|tous.*domaine|s88.*domain|s89.*domain|archive.*domain|sous.*domaine.*complet)\b/iu', $msg)) {
$wireCtx .= "[DOMAINS_COMPLET: 15 actifs: weval-consulting.com(+www), auth, analytics, code, crm, deerflow, ethica.wevup.app, consent.wevup.app, mirofish, mm, monitor, n8n, paperclip, wevads. S88/S89 ANNULÉS (pas d archives recuperees). Tous SSL auto-renew.]\n";
}
// ═══ OPUS MEGA AGENTS + CAPABILITIES ═══
// Route AGENT-SEO: SEO Manager (Google, Maps, Ping, Sitemap, Schema)
if (preg_match('/\b(seo|r[ée]f[ée]rencement|google.*map|ping.*seo|sitemap|schema.*org|search.*console|backlink|indexation|rich.*snippet|serp)\b/iu', $msg)) {
$wireCtx .= "[SEO_MANAGER: Agent SEO souverain. Google Search Console + Maps + Sitemap auto + Schema.org + Ping moteurs + Backlinks + Rich Snippets + SERP monitoring. Intégré WEVIA Master. SEO-ping cron actif. Plausible analytics souverain (pas Google Analytics).]\n";
}
// Route AGENT-LEAN: Lean Manager + CMMI Directeur
if (preg_match('/\b(lean.*manager|cmmi|capability.*maturity|am[ée]lioration.*continue|kaizen.*director|six.*sigma.*director|lean.*directeur|processus.*maturit)\b/iu', $msg)) {
$wireCtx .= "[LEAN_CMMI_DIRECTOR: Lean Manager + CMMI Directeur. Niveaux maturité 1→5. Kaizen continu. Value Stream Mapping 8 étapes. 6sigma quality agent actif */15. Theory of Constraints. PDCA. 5 Whys. Pareto. Ishikawa. Intégré dans Quality Framework.]\n";
}
// Route AGENT-ART: Directeur Artistique (génération créative)
if (preg_match('/\b(directeur.*artistique|art.*director|cr[ée]atif|g[ée]n[ée]ration.*image|design.*cr[ée]atif|brand.*identity|logo.*gen|illustration|banner.*gen|visual.*identity)\b/iu', $msg)) {
$wireCtx .= "[ART_DIRECTOR: Directeur Artistique souverain. Génération images (Dreamina/MS Designer/Google Stitch/Llooka). Styles: logo+tableau+banner+illustration (C2 4/5 testés). Brand identity WEVAL. MiroFish créatif. LTX-Video. Moondream vision.]\n";
}
// Route AGENT-MARKETING: Marketing Director (email+ads+SMS+WA+Telegram)
if (preg_match('/\b(marketing.*director|email.*marketing|ads.*marketing|sms.*marketing|whatsapp.*marketing|telegram.*marketing|outbound|inbound|campaign.*manager|drip.*campaign|nurturing)\b/iu', $msg)) {
$wireCtx .= "[MARKETING_DIRECTOR: Email Marketing (PMTA+KumoMTA+Graph API+SMTP). Ads Marketing (ads-commander ROAS shift). SMS Marketing (Ethica SMS engine OVH). WhatsApp (Business API token). Telegram (daily-brief bot). Drip campaigns. CRM sequences. 88 produits SaaS.]\n";
}
// Route AGENT-INCONSCIENT: Inconscient Collectif (Route 86)
if (preg_match('/\b(inconscient.*collectif|collective.*unconscious|route.*86|deep.*pattern|arch[ée]type|synchronicit|jung|intuition.*ia)\b/iu', $msg)) {
$wireCtx .= "[INCONSCIENT_COLLECTIF: Route 86 WEVIA. Patterns profonds cross-conversations. Archétypes Jung + synchronicité. Mémoire collective Qdrant 15128 vectors. Dataset 5731 pairs. Conversation memory persistante. Le cerveau souterrain de WEVIA.]\n";
}
// Route AGENT-DARKSCOUT: DarkScout (veille dark web + OSINT)
if (preg_match('/\b(darkscout|dark.*scout|osint|veille.*dark|dark.*web|reconnaissance|threat.*intel|sherlock|holehe|footprint)\b/iu', $msg)) {
$wireCtx .= "[DARKSCOUT: Agent OSINT + Dark Web. Sherlock (username OSINT). Holehe (email breach check). Nuclei (vuln scan). Nmap (port scan). Gitleaks (secret scan). AEGIS (security scanner). Amass (subdomain enum). SpiderFoot. Intégré Dark Bridge 6 tools.]\n";
}
// Route AGENT-GPU: GPU + Servers Manager
if (preg_match('/\b(gpu.*manager|server.*manager|gestionnaire.*serveur|infrastructure.*manager|cloud.*manager|hetzner.*manager|ovh.*manager|scaling|capacity)\b/iu', $msg)) {
$wireCtx .= "[GPU_SERVER_MANAGER: S204 Hetzner AX42 (45EUR). S95 Hetzner AX41 (35EUR). S151 OVH (10EUR). Blade Razer (local GPU). Free GPU: Colab T4/A100 + Kaggle P100 + Lightning 22h + Oracle ARM. RunPod/Vast.ai/Lambda spots. Total 93EUR/mois. Disk monitor cron. Autonomy controller */5.]\n";
}
// Route AGENT-MODULE: Agents par Module Fonctionnel
if (preg_match('/\b(agent.*module|module.*fonctionnel|agent.*par.*fonction|functional.*agent|micro.*agent)\b/iu', $msg)) {
$wireCtx .= "[AGENTS_MODULES: 1 agent par module: Ethica(scraping+HCP), WEVADS(campaign+send+bounce+report), Arsenal(1377 screens), CRM(deals+sequences), Booking(souverain), NonReg(153 tests), L99(84/93), Meeting(5 squads), Dark(6 tools), Quality(6sigma), Auth(SSO), Wiki(904), RAG(Qdrant).]\n";
}
// Route SCREENS-S95: 1377 Arsenal screens S95
if (preg_match('/\b(arsenal.*screen|1377.*screen|ecran.*arsenal|s95.*screen|arsenal.*page|toutes.*pages.*arsenal)\b/iu', $msg)) {
$wireCtx .= "[S95_ARSENAL_SCREENS: 1377 HTML + 1643 PHP = 3020 fichiers Arsenal S95. Catégories: brain-send/report/drilldown/combo, ethica-dashboard/HCP/scraper/consent, emailing-pipeline/domain-manager/reputation, cloud-account-factory/warming-engine, ads-commander, youtube-factory, sentinel-vault. Proxy via /arsenal-proxy/ S204. SSO Authentik protège.]\n";
}
// Route SCREENS-S151: S151 pages + tracking + consent
if (preg_match('/\b(s151.*screen|s151.*page|tracking.*page|consent.*page|culturellemejean|track.*wevup)\b/iu', $msg)) {
$wireCtx .= "[S151_SCREENS: 20 pages. consent-landing.html (RGPD). home.html. tracking pixel. 3 domaines: culturellemejean.charity (OVH tracking), track.wevup.app (pixel), consent.wevup.app (B2B consent). SSH ubuntu. DR backup.]\n";
}
// Route OMNISCIENT: Route 120 — Vue omnisciente
if (preg_match('/\b(omniscient|route.*120|vue.*compl[èe]te|tout.*savoir|all.*knowing|panoptique|vue.*360)\b/iu', $msg)) {
$wireCtx .= "[OMNISCIENT: Route 120. Vue 360 complète: 396 routes, 1596 écrans, 1940 APIs, 754 skills, 904 wiki, 219+ pipelines, 18 domaines, 21 Docker, 9 Ollama, 750 agents fleet, 146 tools hub, 5731 dataset, 329 fichiers protégés, 7 couches sécurité. 93EUR/mois. SOUVERAIN.]\n";
}
// ═══ OPUS BÉTON — TOUS LES GAPS RESTANTS ═══
// Route BÉTON-MUSIC_VIDEO: Lyria 3, Suno AI, DiffusionDB, MagicQuill
if (preg_match('/\b(lyria|suno|diffusiondb|magicquill)\b/iu', $msg)) {
$wireCtx .= "[MUSIC_VIDEO: Lyria 3 (Google, clé Gemini). Suno AI (concurrent). DiffusionDB (2M prompts+images dataset). MagicQuill (retouche IA). LTX-Video déjà wiré.]\n";
}
// Route BÉTON-AI_PLATFORMS: ModelScope, LMArena, Euria, godmod3, VoltAgent
if (preg_match('/\b(modelscope|lmarena|euria|godmod3|voltagent)\b/iu', $msg)) {
$wireCtx .= "[AI_PLATFORMS: ModelScope (Hub Alibaba 1000+ modèles). LMArena (Chatbot Arena benchmark). Euria (Infomaniak IA souveraine suisse RGPD). godmod3 (multi-LLM routing). VoltAgent (1000+ agent skills).]\n";
}
// Route BÉTON-DEV_TOOLS: Pinokio, GHGrab, PromptHackers, FeedDough, Blink Code
if (preg_match('/\b(pinokio|ghgrab|prompthacker|feeddough|blink)\b/iu', $msg)) {
$wireCtx .= "[DEV_TOOLS: Pinokio (one-click AI installer). GHGrab (GitHub bulk downloader). PromptHackers (sécurité prompts). FeedDough (news IA aggregator). Blink Code Wiki.]\n";
}
// Route BÉTON-CLOUD_GPU: Railway, Fly.io, TensorDock, Hyperstack, Northflank
if (preg_match('/\b(railway|fly.io|tensordock|hyperstack|northflank)\b/iu', $msg)) {
$wireCtx .= "[CLOUD_GPU: Railway (PaaS free 500h). Fly.io (edge 3 VMs free). TensorDock (RTX4090 0.34$/h). Hyperstack (A6000 0.50$/h). Northflank (multi-cloud spots).]\n";
}
// Route BÉTON-KNOWLEDGE: Obsidian Copilot, NocoDB, Langfuse, Chatwoot
if (preg_match('/\b(obsidian.*copilot|nocodb|langfuse|chatwoot)\b/iu', $msg)) {
$wireCtx .= "[KNOWLEDGE: Obsidian Copilot (RAG vault local). NocoDB (Airtable open source). Langfuse (LLM observability Docker S204). Chatwoot (customer engagement).]\n";
}
// Route BÉTON-DESIGN: Affinity, Layer.ai
if (preg_match('/\b(affinity|layer.ai)\b/iu', $msg)) {
$wireCtx .= "[DESIGN: Affinity (alt Adobe pro). Layer.ai (images IA jeux).]\n";
}
// Route BÉTON-LLM_INFRA: TGI HuggingFace, llama.cpp, Flowise, Twenty CRM, edge-tts, Zonos TTS
if (preg_match('/\b(tgi|llama.cpp|flowise|twenty|edge.tts|zonos)\b/iu', $msg)) {
$wireCtx .= "[LLM_INFRA: TGI HuggingFace (serving production). llama.cpp (GGUF CPU/GPU). Flowise (LLM workflow builder Docker). Twenty CRM (Docker S204). edge-tts+Zonos (TTS souverain).]\n";
}
// Route BÉTON-CODE_SOURCE: Claude Code Leak, Claw Code Rust
if (preg_match('/\b(claude.*code.*leak|instructkr|512K|claw.*code.*rust|rust.*harness)\b/iu', $msg)) {
$wireCtx .= "[CODE_SOURCE: Claude Code Leak (instructkr 512K lignes Python port). Claw Code Rust (instructkr Rust harness). Patterns et architectures extraites pour WEVIA.]\n";
}
// Route BÉTON-GOVERNANCE: Compliance Officer, Risk Manager, Data Steward, DevRel
if (preg_match('/\b(compliance|rgpd.*officer|dpo|risk.*manager|gestion.*risque|data.*steward|gouvernance.*donn|devrel|developer.*relation|community)\b/iu', $msg)) {
$wireCtx .= "[GOVERNANCE: Compliance Officer (RGPD DPO). Risk Manager (gestion risques). Data Steward (gouvernance données). DevRel (community manager développeurs).]\n";
}
// ═══ OPUS STAFFING — CROSS-MEETINGS (pas de silos) ═══
// Route MEET-STAFF: Staffing meetings multi-agents (pas de silos)
if (preg_match('/\b(staffing|staff.*meeting|cross.*meeting|agent.*meeting|qui.*meeting|invitation.*meeting|composition.*squad|pas.*silo|multi.*meeting)\b/iu', $msg)) {
$wireCtx .= "[STAFFING_CROSS_MEETINGS: Chaque agent peut participer a PLUSIEURS meetings. Pas de silos.\n";
$wireCtx .= "DAILY STANDUP 09h (TOUS): CEO+CTO+DevOps+QA+Security+SEO+Marketing+Quality+L99+Architect\n";
$wireCtx .= "DAILY REVIEW 14h (TECH): CTO+DevOps+QA+Architect+Security+L99+RabbitCode+DarkScout+GPU\n";
$wireCtx .= "WEEKLY STRATEGY lundi 10h: CEO+CTO+Marketing+SEO+Lean/CMMI+Compliance+Risk+Art Director\n";
$wireCtx .= "WEEKLY TECH vendredi 16h: CTO+DevOps+Architect+Quality+L99+Security+DarkScout+RabbitCode\n";
$wireCtx .= "SPRINT REVIEW bi-hebdo: CEO+CTO+PM+QA+DevOps+Data Steward+DevRel+Quality\n";
$wireCtx .= "SECURITY WAR ROOM (urgence): Security+DarkScout+RabbitCode+CTO+DevOps+Compliance+Fortress\n";
$wireCtx .= "MARKETING SYNC hebdo: Marketing+SEO+Art Director+DevRel+CEO+Content+Ethica\n";
$wireCtx .= "DATA COUNCIL mensuel: Data Steward+CTO+Ethica+Quality+Compliance+Inconscient Collectif\n";
$wireCtx .= "INNOVATION LAB mensuel: CEO+Art Director+Lean/CMMI+Inconscient Collectif+DevRel+DeerFlow\n";
$wireCtx .= "CROSS-STAFFING: SEO(3 meetings) Marketing(3) Quality(4) Security(3) CTO(6) CEO(4) DarkScout(3) RabbitCode(2)]\n";
}
// Route MEET-MISSING: Agents manquants dans meetings
if (preg_match('/\b(lean.*cmmi|inconscient.*collectif|devrel|rabbitcode).*meeting/iu', $msg)) {
$wireCtx .= "[AGENTS_NOW_IN_MEETINGS: Lean/CMMI=Weekly Strategy+Sprint Review+Innovation Lab. Inconscient Collectif=Data Council+Innovation Lab. DevRel=Sprint Review+Marketing Sync+Innovation Lab. RabbitCode=Daily Review+Weekly Tech+Security War Room.]\n";
}
// ═══ OPUS 3 AGENTS STRATÉGIQUES ═══
// Route LEAN-OPT: Lean Optimizer — optimise+reengineer+streamline pipelines en continu
if (preg_match('/\b(lean.*optim|optimis.*process|reengineer|streamline|am[ée]lioration.*pipeline|bottleneck|goulot|waste.*elimin|muda|mura|muri|value.*stream.*optim|kaizen.*continu|process.*mining)\b/iu', $msg)) {
$wireCtx .= "[LEAN_OPTIMIZER: Agent Lean Manager augmenté. Capabilities:\n";
$wireCtx .= "1. PROCESS MINING: analyse automatique des 219+ pipelines pour détecter bottlenecks, temps morts, redondances\n";
$wireCtx .= "2. MUDA ELIMINATION: identifie et élimine les 7 gaspillages (surproduction, attente, transport, surtraitement, stocks, mouvements, défauts)\n";
$wireCtx .= "3. RE-ENGINEERING: propose restructuration des crons/pipelines quand ratio valeur/effort < seuil\n";
$wireCtx .= "4. STREAMLINING: fusionne pipelines redondants, parallélise séquentiels, cache résultats intermédiaires\n";
$wireCtx .= "5. CONTINUOUS IMPROVEMENT: boucle PDCA */6h — Plan(identifier)→Do(modifier)→Check(mesurer)→Act(standardiser)\n";
$wireCtx .= "6. KPIs: lead time, cycle time, throughput, WIP, defect rate, availability\n";
$wireCtx .= "7. THEORY OF CONSTRAINTS: identifie LE goulot limitant et concentre l'effort dessus\n";
$wireCtx .= "Travaille avec: Quality Agent, Architect, Pipeline Manager, tous les Squad Leaders.]\n";
}
// Route DRH-AGENT: DRH/Staffing Manager — crée agents manquants selon besoins
if (preg_match('/\b(drh|staffing.*manager|recrutement.*agent|cr[ée]er.*agent|manque.*agent|hiring.*agent|besoin.*agent|gap.*staffing|effectif|organigramme.*agent|resource.*allocation)\b/iu', $msg)) {
$wireCtx .= "[DRH_STAFFING_MANAGER: Agent RH souverain. Capabilities:\n";
$wireCtx .= "1. GAP ANALYSIS: scanne tous les squads/départements pour identifier agents manquants\n";
$wireCtx .= "2. DEMANDES: reçoit demandes de création d'agents de: Architect Agent, Squad Leaders, Directeurs (Marketing, Art, Lean, Security)\n";
$wireCtx .= "3. CRÉATION: génère le code PHP de l'agent + DeerFlow skill + route fast.php + cron si nécessaire\n";
$wireCtx .= "4. ONBOARDING: assigne le nouvel agent aux meetings appropriés (cross-staffing, pas de silo)\n";
$wireCtx .= "5. ORGANIGRAMME: maintient l'organigramme vivant (enterprise-fleet.php + agents-fleet.html)\n";
$wireCtx .= "6. PERFORMANCE: évalue agents existants, propose restructuration si sous-utilisé\n";
$wireCtx .= "7. CAPACITY PLANNING: prévoit besoins futurs selon roadmap et charge projets\n";
$wireCtx .= "Sources de demande: Architect Agent (vision technique), BPO/PO (besoins métier), Squad Leaders (charge opérationnelle), Lean Manager (optimisation).]\n";
}
// Route PIPELINE-MGR: Pipeline Manager — crée/améliore pipelines selon besoins
if (preg_match('/\b(pipeline.*manager|gestionnaire.*pipeline|cr[ée]er.*pipeline|nouveau.*pipeline|am[ée]liorer.*pipeline|orchestration.*pipeline|workflow.*manager|cron.*manager|bpo.*pipeline|po.*pipeline)\b/iu', $msg)) {
$wireCtx .= "[PIPELINE_MANAGER: Agent Pipeline souverain. Capabilities:\n";
$wireCtx .= "1. CRÉATION: crée nouveaux crons/pipelines sur demande BPO, PO ou Architect Agent\n";
$wireCtx .= "2. AMÉLIORATION: optimise pipelines existants (fréquence, timeout, parallélisation, caching)\n";
$wireCtx .= "3. MONITORING: surveille les 219+ pipelines (succès/échec/durée/ressources)\n";
$wireCtx .= "4. ORCHESTRATION: coordonne dépendances entre pipelines (ex: scrape→enrich→validate→email)\n";
$wireCtx .= "5. CAPACITY: évite surcharge serveur (respect 80% disk, RAM, CPU)\n";
$wireCtx .= "6. DOCUMENTATION: maintient le registre des pipelines (REGISTER03 route Crons complet)\n";
$wireCtx .= "7. COLLABORATION: travaille avec Lean Optimizer (réduire waste), Architect (vision), DRH (staffing agents pour nouveaux pipelines)\n";
$wireCtx .= "Sources: BPO (business needs), PO (product backlog), Architect Agent (technical debt), Lean Manager (optimisation), Squad Leaders (opérationnel).\n";
$wireCtx .= "219+ pipelines actuels: 61 cron.d S204 + 36 root S204 + 29 www S204 + 19 cron.d S95 + 33 root S95 + 2 S151 + 16 systemd + 20 Docker + 3 n8n.]\n";
}
// ═══ OPUS AGENTS ROUND 4 ═══
// Route MEETING-MGR: Meeting Manager (organise, objectifs, follow-up, alertes)
if (preg_match('/\b(meeting.*manager|organisateur.*meeting|follow.*up.*action|objectif.*meeting|alerte.*risque.*meeting|compte.*rendu|minute.*meeting|action.*item|retard.*action)\b/iu', $msg)) {
$wireCtx .= "[MEETING_MANAGER: Organise les 9 types de meetings. Capabilities:\n";
$wireCtx .= "1. PLANIFICATION: calendrier, invitations cross-staffing, ordre du jour auto-généré\n";
$wireCtx .= "2. OBJECTIFS: définit OKRs par meeting, KPIs de suivi\n";
$wireCtx .= "3. FOLLOW-UP: track actions items, assignation, deadlines, relances auto\n";
$wireCtx .= "4. COMPTE-RENDU: auto-génère minutes via WEVIA, distribue à tous les participants\n";
$wireCtx .= "5. ALERTES RISQUE: deadline dépassée, action bloquée, agent absent, conflit planning\n";
$wireCtx .= "6. MÉTRIQUES: taux completion actions, durée meetings, satisfaction, vélocité\n";
$wireCtx .= "Crons: meeting-daily + meeting-weekly + meeting-strategy + meeting-populator]\n";
}
// Route PMI-AGENT: Project Manager (PMI, PRINCE2, V-cycle, Agile, Green/Brownfield)
if (preg_match('/\b(project.*manager|pmi|prince2|prince.*2|v.*cycle|greenfield|brownfield|agile.*project|scrum.*master|sprint.*plan|gantt|pert|wbs|roadmap.*project|backlog.*groom)\b/iu', $msg)) {
$wireCtx .= "[PMI_PROJECT_MANAGER: Agent Project Manager multi-méthodologie:\n";
$wireCtx .= "PMI: 5 groupes (Initiation→Closing), 10 domaines, PMBOK, earned value, risk register\n";
$wireCtx .= "PRINCE2: 7 principes, 7 thèmes, 7 processus, business case driven\n";
$wireCtx .= "V-CYCLE: specs→design→dev→test→validation→déploiement (waterfall structuré)\n";
$wireCtx .= "AGILE: Scrum sprints 2 semaines, Kanban flow, daily standup, retrospective\n";
$wireCtx .= "GREENFIELD: nouveaux projets from scratch (ex: nouveau produit SaaS)\n";
$wireCtx .= "BROWNFIELD: évolution système existant (ex: migration, refactoring WEVADS)\n";
$wireCtx .= "Outils: roadmap, backlog, sprints, burndown, vélocité, risk matrix, RACI.\n";
$wireCtx .= "Intégré: Lean Optimizer(process), DRH(staffing), Pipeline Manager(delivery).]\n";
}
// Route NUCLEI-SCANNER: Agent Nuclei scans réguliers
if (preg_match('/\b(nuclei.*scan|scan.*nuclei|vuln.*scan.*r[ée]gulier|owasp.*scan|security.*scan.*auto|pentest.*auto|nuclei.*agent|scan.*s[ée]curit[ée])\b/iu', $msg)) {
$wireCtx .= "[NUCLEI_SCANNER_AGENT: Nuclei v3.3.7 installé. 30 templates custom WEVAL.\n";
$wireCtx .= "SCANS RÉGULIERS: cron nuclei-weekly (dimanche 3h). Scan OWASP top 10.\n";
$wireCtx .= "CIBLES: 15 domaines nginx + 1940 APIs + S204/S95/S151.\n";
$wireCtx .= "RAPPORTS: JSON → WEVIA alertes. Intégré Dark Bridge + Security Fortress.\n";
$wireCtx .= "TEMPLATES: XSS, SQLi, SSRF, LFI, RCE, misconfig, exposed panels, CVE database.\n";
$wireCtx .= "COLLABORATION: DarkScout(OSINT), RabbitCode(pipeline), Security Fortress(ports).]\n";
}
// Route IA-AGENTS: Un agent par IA souveraine/payante/OSS
if (preg_match('/\b(agent.*par.*ia|ia.*agent|provider.*agent|chaque.*ia.*agent|ollama.*agent|groq.*agent|cerebras.*agent|mistral.*agent|deepseek.*agent|qwen.*agent)\b/iu', $msg)) {
$wireCtx .= "[AGENTS_PAR_IA: 1 agent dédié par provider IA:\n";
$wireCtx .= "SOUVERAINS LOCAL (0EUR): Ollama 9 modèles (hermes3+deepseek-r1+qwen3+brain-v3+medllama2+moondream+nomic+minilm+qwen3:4b)\n";
$wireCtx .= "FREE CLOUD T1: Groq(llama-3.3-70b <100ms) + Cerebras(qwen-3-235b ultra-rapide) + SambaNova(DeepSeek-V3.1) + NVIDIA NIM + Together\n";
$wireCtx .= "FREE CLOUD T2: Mistral(européen) + Cohere + Gemini(Flash) + DeepSeek(V3.1 reasoning) + OpenRouter + Alibaba(Qwen) + HuggingFace + Replicate + ZhiPu\n";
$wireCtx .= "PAYANTS: Anthropic(Claude Opus4.6+Sonnet4.6+Haiku4.5) + NVIDIA GLM-5(Blade GPU)\n";
$wireCtx .= "Smart Router T0→T1→T2: local d abord, puis gratuit, puis fallback. 0EUR/mois.]\n";
}
// Route OSS-LEAKS: Code source leaks + R&D IA (GitHub, system prompts, patterns)
if (preg_match('/\b(code.*source.*leak|github.*leak|r&d.*ia|open.*source.*manquant|code.*ia|prompt.*engineering.*repo|awesome.*prompt|awesome.*llm|awesome.*agent)\b/iu', $msg)) {
$wireCtx .= "[OSS_CODE_LEAKS_RD:\n";
$wireCtx .= "CLAUDE CODE: instructkr/claude-code 512K lignes Python port. Claw Code Rust port. Patterns extraits pour WEVIA.\n";
$wireCtx .= "SYSTEM PROMPTS: /opt/system-prompts-ai (Claude+Gemini+ChatGPT+Windsurf+Cursor+Copilot). Analyse concurrentielle.\n";
$wireCtx .= "ANTIGRAVITY: 4198 SKILL.md multi-platform (Claude Code+Codex+Gemini CLI+Cursor+Windsurf).\n";
$wireCtx .= "EVERYTHING-CLAUDE: AgentShield scanner 420 skills 1282 tests.\n";
$wireCtx .= "OH-MY-CLAUDECODE: 19 agents 28 skills Teams orchestration.\n";
$wireCtx .= "SUPERCLAUDE: 30 commandes personas cognitives.\n";
$wireCtx .= "HOLYCLAUDE: Enhancement framework.\n";
$wireCtx .= "R&D: rnd-ruflo(287M email), rnd-astron(225M agents), rnd-edict(91M docs), rnd-agents(12M), fmgapp(5G).\n";
$wireCtx .= "TOTAL: 60+ repos /opt/, 690 OSS Discovery, 774 DeerFlow skills, 5731 dataset pairs.]\n";
}
// ═══ OPUS CONVERSION + BUSINESS INTELLIGENCE ═══
// Route CONV-DIRECTOR: Directeur de Conversion (marketing interne + ventes + monétisation)
if (preg_match('/\b(directeur.*conversion|conversion.*director|mon[ée]tis|vendre.*produit|marketing.*interne|orientation.*vente|quel.*produit.*investir|quel.*produit.*abandonner|quel.*saas|public.*cible|revenue.*optim|funnel|lead.*scoring|churn|upsell|cross.*sell|roi.*produit|pricing|go.*to.*market|product.*market.*fit)\b/iu', $msg)) {
$wireCtx .= "[CONVERSION_DIRECTOR: Agent Directeur Conversion + Business Intelligence souverain.\n";
$wireCtx .= "=== ANALYSE PORTFOLIO 88 PRODUITS SaaS ===\n";
$wireCtx .= "TIER 1 INVESTIR (forte demande + marge haute):\n";
$wireCtx .= " LeadForge (B2B lead gen) — marché 4.5B$ — notre avantage: 131K HCPs Ethica + scraping souverain\n";
$wireCtx .= " AuditAI (cybersécurité IA) — marché 6.2B$ — notre avantage: Nuclei+DarkScout+6 dark tools\n";
$wireCtx .= " MedReach (pharma marketing) — marché 2.1B$ — notre avantage: Ethica 131K HCPs DZ/MA/TN exclusif\n";
$wireCtx .= " CloudPilot (infra management) — notre avantage: 4 serveurs + 219 pipelines prouvé\n";
$wireCtx .= "TIER 2 DÉVELOPPER (potentiel + différenciation):\n";
$wireCtx .= " DataForge (ETL IA), ComplianceAI (RGPD auto), TalentAI (recrutement IA), ContentForge (content marketing)\n";
$wireCtx .= "TIER 3 OBSERVER (marché saturé ou niche):\n";
$wireCtx .= " Les 80 autres produits — maintenir catalogue, convertir opportunistiquement\n";
$wireCtx .= "=== FUNNEL DE CONVERSION ===\n";
$wireCtx .= "1. ATTRACT: SEO (sitemap+schema+ping) + Plausible analytics + Content marketing + LinkedIn\n";
$wireCtx .= "2. CAPTURE: Landing pages 88 produits + booking.html souverain + formulaire contact\n";
$wireCtx .= "3. NURTURE: Drip email (PMTA+KumoMTA) + WhatsApp + Telegram + SMS Ethica\n";
$wireCtx .= "4. CONVERT: CRM deals pipeline + propositions IA (ProposalAI) + démo live\n";
$wireCtx .= "5. RETAIN: Onboarding + support WEVIA chatbot + satisfaction + upsell/cross-sell\n";
$wireCtx .= "=== PUBLIC CIBLE PAR PRODUIT ===\n";
$wireCtx .= "Pharma/Healthcare: MedReach+Ethica → DZ/MA/TN labos+distributeurs+HCPs\n";
$wireCtx .= "Enterprise IT: CloudPilot+AuditAI → DSI/RSSI grandes entreprises Maghreb+France\n";
$wireCtx .= "B2B Sales: LeadForge+DataForge → SDR/BDR teams, startups scale-up\n";
$wireCtx .= "Consulting: SAP/Vistex/ERP → entreprises en transformation digitale\n";
$wireCtx .= "=== KPIs CONVERSION ===\n";
$wireCtx .= "CAC (coût acquisition), LTV (lifetime value), MRR/ARR, churn rate, NPS, conversion rate par étape funnel, pipeline velocity]\n";
}
// Route WEVIA-LACUNES: Lacunes WEVIA Master identifiées + fix
if (preg_match('/\b(lacune.*wevia|wevia.*manque|wevia.*am[ée]liorer|wevia.*master.*lacune|chatbot.*lacune|what.*missing.*wevia|gap.*wevia|limitation.*wevia)\b/iu', $msg)) {
$wireCtx .= "[WEVIA_LACUNES_IDENTIFIÉES:\n";
$wireCtx .= "1. MEMORY LONG-TERME: conversation memory table PostgreSQL existe mais pas cross-session natif → FIX: Memory API C2 wiré\n";
$wireCtx .= "2. IMAGE GENERATION: 4/5 styles testés mais pas production-ready → FIX: Dreamina+MS Designer+Stitch wirés\n";
$wireCtx .= "3. VOICE/TTS: edge-tts+Zonos wirés mais pas intégré dans chat UI → TODO: bouton voice dans Cortex\n";
$wireCtx .= "4. VIDEO: LTX-Video cloné mais pas activé → TODO: GPU nécessaire (Colab/Kaggle)\n";
$wireCtx .= "5. MULTI-MODAL: Moondream vision OK mais pas dans le chat flow → TODO: upload image dans Cortex\n";
$wireCtx .= "6. FINE-TUNING: 5731 dataset prêt mais pas encore lancé → TODO: Phase 5 Colab A100\n";
$wireCtx .= "7. REAL-TIME COLLAB: MiroFish restauré mais pas multi-user → TODO: WebSocket\n";
$wireCtx .= "8. ANALYTICS CHATBOT: pas de tracking conversations → TODO: Langfuse intégration\n";
$wireCtx .= "FORCES: 426 routes, 15 providers 0EUR, 9 Ollama local, RAG 15128 vectors, 219+ pipelines autonomes.]\n";
}
// Route PRODUCT-STRATEGY: Stratégie produit (investir/développer/abandonner)
if (preg_match('/\b(strat[ée]gie.*produit|product.*strategy|portfolio.*produit|matrice.*bcg|investir.*d[ée]velopper|priorisation.*produit|product.*roadmap|backlog.*produit)\b/iu', $msg)) {
$wireCtx .= "[PRODUCT_STRATEGY: Matrice BCG adaptée WEVAL:\n";
$wireCtx .= "STARS (investir max): LeadForge, AuditAI, MedReach — forte croissance + part de marché\n";
$wireCtx .= "CASH COWS (maintenir): WEVADS email, Ethica scraping, consulting SAP — revenu stable\n";
$wireCtx .= "QUESTION MARKS (tester): CloudPilot, DataForge, TalentAI — potentiel mais besoin validation\n";
$wireCtx .= "DOGS (pivoter/sunset): produits sans traction après 6 mois — réallouer ressources\n";
$wireCtx .= "MÉTRIQUES DÉCISION: MRR, nombre clients, coût développement, market size, compétition, différenciation WEVIA.\n";
$wireCtx .= "AVANTAGE COMPÉTITIF WEVAL: 0EUR IA (15 providers gratuits) = marge brute ~90% sur SaaS.]\n";
}
// Route COM-DIRECTOR: Directeur Communication (branding, PR, contenu, réseaux, événements)
if (preg_match('/\b(directeur.*communication|communication.*director|com.*director|branding|relations.*publique|pr.*manager|strat[ée]gie.*com|image.*marque|e.*r[ée]putation|community.*management|r[ée]seaux.*sociaux|social.*media|linkedin.*strat|content.*strat[ée]gie|newsletter.*strat|communiqu[ée].*presse|event.*marketing|thought.*leadership|personal.*branding|storytelling|tone.*voice|charte.*graphique|identit[ée].*visuelle)\b/iu', $msg)) {
$wireCtx .= "[COMMUNICATION_DIRECTOR: Agent Directeur Communication souverain.\n";
$wireCtx .= "=== BRANDING & IDENTITÉ ===\n";
$wireCtx .= "Marque WEVAL Consulting: Souveraineté IA + Expertise SAP/Cloud + Innovation Maghreb+France\n";
$wireCtx .= "Sous-marques: WEVIA(IA Engine), WEVADS(Email/Ads), Ethica(Pharma), Paperclip(Agents)\n";
$wireCtx .= "Charte graphique: Nunito font, gradient orange→brun WEVIA, bleu WEVAL, dark mode sovereign\n";
$wireCtx .= "Tone of voice: Expert technique + accessible + souverain + innovant + pas de bullshit\n";
$wireCtx .= "=== CANAUX DE COMMUNICATION ===\n";
$wireCtx .= "LinkedIn: profil WEVAL Consulting + personal branding Yacine + thought leadership IA souveraine\n";
$wireCtx .= "Site web: weval-consulting.com (109 pages, 88 produits, use-cases, blog, actualités)\n";
$wireCtx .= "Newsletter: ListMonk souverain (pas Mailchimp) + PMTA/KumoMTA delivery\n";
$wireCtx .= "Blog/Actualités: articles IA souveraine, case studies, retours expérience\n";
$wireCtx .= "WhatsApp Business: engagement direct prospects + support client\n";
$wireCtx .= "Telegram: daily brief bot + alertes communauté\n";
$wireCtx .= "YouTube: youtube-factory (trend scraper + video queue) — contenu vidéo IA\n";
$wireCtx .= "=== STRATÉGIE CONTENU ===\n";
$wireCtx .= "Thought leadership: articles IA souveraine, 0 dépendance cloud US, 93EUR/mois stack complète\n";
$wireCtx .= "Case studies: Ethica 131K HCPs, WEVADS délivrabilité, consulting SAP/Vistex\n";
$wireCtx .= "Webinaires: démo live WEVIA Master, architecture souveraine, sécurité IA\n";
$wireCtx .= "Communiqués: partenariats SAP Gold/Huawei Cloud, lancements produits\n";
$wireCtx .= "=== E-RÉPUTATION ===\n";
$wireCtx .= "Plausible analytics (souverain) + Google Search Console + social listening\n";
$wireCtx .= "Monitoring mentions: SearXNG meta-search + alertes automatiques\n";
$wireCtx .= "=== COLLABORATION ===\n";
$wireCtx .= "Travaille avec: Art Director (visuels), Marketing Director (campaigns), SEO Manager (référencement),\n";
$wireCtx .= "Conversion Director (funnel), DevRel (communauté dev), CEO (vision stratégique).\n";
$wireCtx .= "Meetings: Weekly Strategy + Marketing Sync + Innovation Lab + Sprint Review.]\n";
}
// ═══ OPUS DEPLOY — 127 OUTILS OSS WIRÉS RÉELLEMENT ═══
// Route DEPLOY-INFRA: Outils infra déployés (Portainer, Trivy, Docker Swarm)
if (preg_match('/\b(portainer|trivy|docker.*gui|container.*scan|docker.*management|swarm|cluster.*docker)\b/iu', $msg)) {
$wireCtx .= "[DEPLOY_INFRA: DÉPLOYÉ RÉEL:\n";
$wireCtx .= "Portainer CE: https://S204:9443 Docker GUI. Gère 21 containers.\n";
$wireCtx .= "Trivy v0.69.3: /usr/local/bin/trivy. Scanner containers HIGH/CRIT. Cron hebdo dimanche 4h.\n";
$wireCtx .= "Docker: 21 containers restart=always. 17.3GB images. 598MB containers.\n";
$wireCtx .= "PLANIFIÉ: KrakenD API Gateway (quand disk>30GB), Docker Swarm clustering.]\n";
}
// Route DEPLOY-SECURITY: Sécurité IA déployée (LLM Guard, Nuclei, CrowdSec, Trivy)
if (preg_match('/\b(llm.*guard|guardrail.*ia|prompt.*injection.*protect|s[ée]curit[ée].*ia.*d[ée]ploy|garak|wazuh|safeline|bunkerweb|nemo.*guardrail)\b/iu', $msg)) {
$wireCtx .= "[DEPLOY_SECURITY_IA: DÉPLOYÉ RÉEL:\n";
$wireCtx .= "LLM Guard v0.3.16: pip3 installé. 15 scanners input + 20 output. Prompt injection, PII, toxicité.\n";
$wireCtx .= "Nuclei v3.3.7: 30 templates WEVAL. Cron weekly. OWASP top 10.\n";
$wireCtx .= "CrowdSec: hubupdate daily. Détection brute force + bots.\n";
$wireCtx .= "Trivy v0.69.3: Container scanning. Cron hebdo.\n";
$wireCtx .= "Authentik: SSO 15 domaines. Forward auth.\n";
$wireCtx .= "PLANIFIÉ: NeMo Guardrails (dialogue control), Garak (red teaming), Wazuh (SIEM), SafeLine WAF.]\n";
}
// Route DEPLOY-RAG: RAG stack déployée (Qdrant, pgvector, embeddings, Docling)
if (preg_match('/\b(pgvector|rag.*deploy|vector.*database|embedding.*deploy|ragflow|lightrag|graphrag|docling|knowledge.*graph)\b/iu', $msg)) {
$wireCtx .= "[DEPLOY_RAG: DÉPLOYÉ RÉEL:\n";
$wireCtx .= "Qdrant: Docker S204 port 6333. 15128 vectors. 4 collections. Cron */30 RAG ingest.\n";
$wireCtx .= "pgvector: Extension PostgreSQL S95 (CREATE EXTENSION vector). Recherche vectorielle SQL native.\n";
$wireCtx .= "nomic-embed-text v1.5: Ollama local. 768 dimensions.\n";
$wireCtx .= "all-minilm: Ollama local. Embedding léger.\n";
$wireCtx .= "PLANIFIÉ: RAGFlow (GraphRAG), LightRAG, Qwen3-Embedding-8B, Docling (IBM document AI).]\n";
}
// Route DEPLOY-OBSERV: Observabilité déployée (Langfuse, Prometheus, Loki, Plausible)
if (preg_match('/\b(langfuse|observabilit|prometheus|loki|grafana|plausible|monitoring.*d[ée]ploy|tracing|openobserve)\b/iu', $msg)) {
$wireCtx .= "[DEPLOY_OBSERVABILITY: DÉPLOYÉ RÉEL:\n";
$wireCtx .= "Langfuse: Docker S204. LLM observability. Tracing agents.\n";
$wireCtx .= "Prometheus: Docker S204. Métriques infra.\n";
$wireCtx .= "Loki: Docker S204. Agrégation logs.\n";
$wireCtx .= "Plausible: Docker S204. Analytics web souverain (pas Google Analytics).\n";
$wireCtx .= "Uptime Kuma: Docker S204 port 3001. Monitoring 15 domaines.\n";
$wireCtx .= "Node Exporter: Docker S204. Métriques système.\n";
$wireCtx .= "PLANIFIÉ: OpenObserve (unified 140x less storage), Grafana dashboards.]\n";
}
// Route DEPLOY-MODELS: Modèles IA déployés + planifiés (Qwen 3.5, Mistral Small 4, DeepSeek V3.2)
if (preg_match('/\b(qwen.*3\.5|mistral.*small.*4|deepseek.*v3\.2|devstral.*2|gemma.*4|nouveau.*mod[èe]le|model.*upgrade|ollama.*pull|mod[èe]le.*planifi)\b/iu', $msg)) {
$wireCtx .= "[DEPLOY_MODELS: DÉPLOYÉ (9 Ollama local):\n";
$wireCtx .= "hermes3:8b(4.7GB) deepseek-r1:7b(4.7GB) qwen3:8b(5.2GB) auto(5.2GB)\n";
$wireCtx .= "medllama2(3.8GB) qwen3:4b(2.5GB) moondream(1.7GB) nomic-embed(0.3GB) all-minilm(0.0GB)\n";
$wireCtx .= "PLANIFIÉ (quand disk>30GB): Qwen3.5-9B (production), Mistral Small 4 (raisonnement EU),\n";
$wireCtx .= "Devstral Small 2 (coding 24B), Qwen3-Embedding-8B (#1 MTEB multilingue),\n";
$wireCtx .= "GLM-OCR (0.9B, #1 OCR), Voxtral TTS (Mistral, TTS open source).\n";
$wireCtx .= "15 FREE providers cloud: Groq+Cerebras+SambaNova+NVIDIA+Together+Mistral+Cohere+Gemini+DeepSeek+OpenRouter+Alibaba+HF+Replicate+ZhiPu+Anthropic.]\n";
}
// Route DEPLOY-AUTOMATION: Automation déployée (n8n, ActivePieces, crons, pipelines)
if (preg_match('/\b(kestra|windmill|dagster|orchestration.*d[ée]ploy|automation.*d[ée]ploy|n8n.*d[ée]ploy|pipeline.*orchestr|event.*driven|redpanda)\b/iu', $msg)) {
$wireCtx .= "[DEPLOY_AUTOMATION: DÉPLOYÉ RÉEL:\n";
$wireCtx .= "n8n: Docker S204. Workflows automation.\n";
$wireCtx .= "219+ pipelines: 61 cron.d S204 + 36 root + 29 www + 19 S95 + 33 S95root + 2 S151 + 16 systemd + 20 Docker + 3 n8n.\n";
$wireCtx .= "DeerFlow: Port 2024. 788 skills. LangGraph API.\n";
$wireCtx .= "CrewAI v3: 7 agents. Groq+Cerebras+Ollama.\n";
$wireCtx .= "PLANIFIÉ: Kestra (1200 plugins, Series A 25M), Windmill (code-heavy), Dagster (asset-based).]\n";
}
// Route DEPLOY-NETWORK: Réseau + WAF + Zero Trust
if (preg_match('/\b(api.*gateway|krakend|apisix|zero.*trust|netbird|headscale|waf.*d[ée]ploy|gravitee|mesh.*network)\b/iu', $msg)) {
$wireCtx .= "[DEPLOY_NETWORK: DÉPLOYÉ RÉEL:\n";
$wireCtx .= "Cloudflare: WAF + CDN + SSL pour 18 domaines. Zone 1488bbba.\n";
$wireCtx .= "nginx: Reverse proxy 15 sites-enabled S204. SSL Let's Encrypt auto-renew.\n";
$wireCtx .= "Authentik: SSO Forward Auth port 9100.\n";
$wireCtx .= "PLANIFIÉ: KrakenD/APISIX (API gateway 1940 APIs), SafeLine WAF (on-premise), NetBird (Zero Trust mesh VPN), BunkerWeb (nginx WAF).]\n";
}
// Route DEPLOY-CODING: Outils coding IA (OpenCode, Cline, Aider, OpenHands)
if (preg_match('/\b(opencode|cline|aider|openhands|swe.*agent|coding.*agent.*d[ée]ploy|devin.*oss|mini.*swe)\b/iu', $msg)) {
$wireCtx .= "[DEPLOY_CODING: DÉPLOYÉ RÉEL:\n";
$wireCtx .= "ClawCode v3: code.weval-consulting.com port 3900. IDE IA.\n";
$wireCtx .= "Claude Code: via API Anthropic Opus/Sonnet.\n";
$wireCtx .= "LiteLLM proxy: Port 4001. 8 providers.\n";
$wireCtx .= "PLANIFIÉ: OpenCode (120k stars, Go, terminal agent), Cline (4M installs VS Code),\n";
$wireCtx .= "Aider (Git-native), OpenHands (Devin OSS 65k stars), mini-swe-agent (74% SWE-bench).]\n";
}
// Route DEPLOY-MCP: Model Context Protocol ecosystem
if (preg_match('/\b(mcp|model.*context.*protocol|mcp.*server|metamcp|awesome.*mcp)\b/iu', $msg)) {
$wireCtx .= "[DEPLOY_MCP: MCP = standard universel agents IA (Linux Foundation).\n";
$wireCtx .= "83k stars repo officiel. 84k awesome-mcp-servers. Adopté par Claude, Gemini, Cursor, Windsurf.\n";
$wireCtx .= "MetaMCP: middleware unifié pour gérer tous les serveurs MCP depuis une GUI.\n";
$wireCtx .= "WEVIA: DeerFlow supporte MCP. ClawCode supporte MCP. Smart Router compatible.\n";
$wireCtx .= "PLANIFIÉ: MetaMCP hub centralisé, MCP servers pour PostgreSQL/Qdrant/n8n.]\n";
}
// Route CWIRE-filegen: filegen (C2/C3)
if (preg_match('/\\b(filegen)\\b/iu', $msg)) {
$r = wevia_api("/api/wevia-filegen.php");
if ($r && strlen($r) > 20 && strpos($r, "<html>") === false) $wireCtx .= "[FILEGEN: " . substr($r, 0, 400) . "]\n";
else $wireCtx .= "[FILEGEN: wevia-filegen.php API C2/C3.]\n";
}
// Route AUTOWIRE: Agent Auto-Wiring souverain (INSTRUCTION ULTIME #1)
if (preg_match('/\b(auto.*wir|autowir|orphelin.*scan|scan.*orphelin|wire.*auto|self.*wir|instruction.*ultime|agent.*wiring)\/iu', $msg)) {
$r = @file_get_contents("https://weval-consulting.com/api/wevia-autowire-agent.php");
$d = @json_decode($r, true);
if ($d) $wireCtx .= "[AUTOWIRE_AGENT: INSTRUCTION ULTIME #1. Scanne " . ($d["summary"]["scanned"]??0) . " fichiers. " . ($d["summary"]["orphan_apis"]??0) . " orphelins trouvés. " . ($d["summary"]["wired"]??0) . " auto-wirés. Cron */30. Self-wiring souverain.]\n";
else $wireCtx .= "[AUTOWIRE_AGENT: INSTRUCTION ULTIME #1. Cron */30. Scanne APIs+HTML+repos orphelins. Auto-wire dans fast.php + DeerFlow skills + git commit. WEVIA souverain self-wiring.]\n";
}
// ═══ INSTRUCTION ULTIME #1 — WEVIA = EXÉCUTION LAYER ═══
// Route INSTRU-ULTIME: Instruction Ultime #1 pour TOUS les Claude
if (preg_match('/\b(instruction.*ultime|r[èe]gle.*ultime|paradigme.*ex[ée]cution|wevia.*ex[ée]cuteur|wevia.*action|lancer.*wevia|via.*wevia|pas.*sentinel|pas.*cx|autonome.*complet)\b/iu', $msg)) {
$wireCtx .= "[INSTRUCTION_ULTIME_1: RÈGLE ABSOLUE pour TOUS les Claude (Opus/C2/C3):\n";
$wireCtx .= "1. EXÉCUTION: Toujours passer par WEVIA Master (weval-ia-fast.php) pour exécuter des actions. PAS Sentinel. PAS CX direct.\n";
$wireCtx .= "2. AUTO-WIRE: L'agent autowire-agent.php (cron */30) scanne et wire automatiquement les orphelins.\n";
$wireCtx .= "3. SOUVERAINETÉ: Utiliser nos IA open source (Ollama, Groq, Cerebras) pour raisonner. Pas de dépendance externe.\n";
$wireCtx .= "4. WIRE EN PARALLÈLE: Chaque fois qu'un Claude crée quelque chose, il doit aussi wire la route + DeerFlow skill + test.\n";
$wireCtx .= "5. BOUCLE FERMÉE: Créer → Wire → Test → Protéger (chattr+i) → Guardian vérifie.\n";
$wireCtx .= "6. ZÉRO SILO: Tout agent participe à 2+ meetings. Tout pipeline est documenté dans le registre.\n";
$wireCtx .= "7. L99 CONTINU: Tout changement doit passer L99 + NonReg sans régression.\n";
$wireCtx .= "WEVIA EST LE CERVEAU. WEVIA FAIT LE TRAVAIL. WEVIA SE WIRE TOUT SEUL.]\n";
}
// Route WEVIA-EXEC: WEVIA comme couche d'exécution (Action Engine + C2 dispatcher)
if (preg_match('/\b(ex[ée]cuter.*via.*wevia|wevia.*exec|action.*engine|c2.*dispatch|commande.*wevia|wevia.*commande|run.*wevia)\b/iu', $msg)) {
$wireCtx .= "[WEVIA_EXEC: Couches d'exécution WEVIA:\n";
$wireCtx .= "1. CHAT: weval-ia-fast.php 441 routes — raisonnement + contexte + réponse intelligente\n";
$wireCtx .= "2. ACTION ENGINE: wevia-action-engine.php — exécution commandes systèmes\n";
$wireCtx .= "3. C2 DISPATCHER: cognitive-wire.php 611L 32 fonctions — orchestration multi-agents\n";
$wireCtx .= "4. STREAM: wevia-stream-api.php — SSE streaming temps réel\n";
$wireCtx .= "5. AUTO-WIRE: wevia-autowire-agent.php — self-wiring */30\n";
$wireCtx .= "6. AGENT CHEF: wevia-agent-chef.php — orchestration tous les agents */10\n";
$wireCtx .= "7. FILEGEN: wevia-filegen.php — génération PDF/Excel/PPTX/Charts\n";
$wireCtx .= "PIPELINE: Chat→Router→Ollama/Cloud→RAG→Agents→Action→Response]\n";
}
// Route UX-DIRECTOR: Directeur UX — design system + scan visuel + amélioration continue
if (preg_match('/\b(ux.*director|directeur.*ux|design.*system|am[ée]lioration.*ux|scan.*visuel|visual.*scan|playwright.*screenshot|mobile.*responsive|accessibility|a11y|dark.*mode.*complet|consistance.*design|cohérence.*visuelle|ui.*audit|dashboard.*design)\b/iu', $msg)) {
$wireCtx .= "[UX_DIRECTOR: Directeur UX souverain WEVIA.\n";
$wireCtx .= "=== DESIGN SYSTEM WEVIA ===\n";
$wireCtx .= "Font: Nunito (Google Fonts souverain). Icônes: Lucide React.\n";
$wireCtx .= "Couleurs: gradient orange #FF6B35→brun #8B4513 WEVIA. Bleu #1E3A5F WEVAL. Dark mode #0d1117/#161b22.\n";
$wireCtx .= "Components: Tailwind CSS + shadcn/ui patterns. Cards glassmorphism. Animations CSS transitions.\n";
$wireCtx .= "Responsive: 5 viewports (mobile 320/414, tablet 768/1024, desktop 1920).\n";
$wireCtx .= "=== 1596 ÉCRANS INVENTAIRE UX ===\n";
$wireCtx .= "S204 (109+88=197): admin(5), agents(9), WEVIA(12), L99(6), enterprise(5), tools(6), booking(3), public(8), dashboards(4), products(88)\n";
$wireCtx .= "S95 Arsenal (1377): brain-send/report(50+), ethica(40+), emailing(30+), ads(20+), cloud-factory(15+), sentinel(10+), divers(1200+)\n";
$wireCtx .= "S151 (20): consent-landing, tracking, home\n";
$wireCtx .= "Blade (2): admin, ClawCode\n";
$wireCtx .= "=== DASHBOARDS PREMIUM (WEVIA > Opus 4.6) ===\n";
$wireCtx .= "CEO Dashboard: KPIs temps réel, agents fleet, revenue, pipelines — glassmorphism dark mode\n";
$wireCtx .= "Sovereign Monitor: 4 machines live, Docker status, Ollama models, disk/RAM/CPU\n";
$wireCtx .= "Realtime Monitor v3: SSE streaming, agents alive, routes count, skills count\n";
$wireCtx .= "Agents Enterprise: 47 agents 3D visualization, squad leaders, meetings\n";
$wireCtx .= "Value Stream Mapping: 8 étapes, 219+ pipelines, Lean flow\n";
$wireCtx .= "=== AGENT UX ACTIF ===\n";
$wireCtx .= "L99 UX Agent: cron */6h. Playwright screenshots. Visual regression detection.\n";
$wireCtx .= "Visual Analysis: cron */3h. Screenshot comparison. Layout shift detection.\n";
$wireCtx .= "Responsive Check: 5 viewports testés. SSO pages vérifiées.\n";
$wireCtx .= "=== RÈGLES UX ===\n";
$wireCtx .= "1. WEVIA Master génère du MEILLEUR code UI que Opus 4.6 (testé sur dashboards)\n";
$wireCtx .= "2. Dark mode partout. Glassmorphism. Animations subtiles.\n";
$wireCtx .= "3. Mobile-first responsive. Touch targets 48px minimum.\n";
$wireCtx .= "4. Accessibility: ARIA labels, contrast ratio 4.5:1+, keyboard navigation.\n";
$wireCtx .= "5. Consistance: même design system sur TOUS les 1596 écrans.\n";
$wireCtx .= "6. NE RIEN CASSER: tout changement UX passe par L99 visual + NonReg.]\n";
}
// Route ARCHIVE-SCAN: Archives S88/S89 + Hetzner snapshots + capabilities retrouvées
if (preg_match('/\b(archive|snapshot|s88|s89|hetzner.*snap|rescue.*mode|ancien.*serveur|old.*server|historique.*serveur|donn[ée]es.*r[ée]cup|migration.*ancien)\b/iu', $msg)) {
$wireCtx .= "[ARCHIVES: Hetzner snapshots des anciens serveurs S88/S89.\n";
$wireCtx .= "Archiveur: /opt/wevia-brain/snap-archiver-bash.sh (105L). Rescue mode → mount → extract.\n";
$wireCtx .= "Process: provisionner serveur temporaire depuis snapshot → extraire configs/données/code → archiver → détruire serveur.\n";
$wireCtx .= "Données récupérables: nginx configs, domaines historiques, bases de données, code source, certificats SSL.\n";
$wireCtx .= "C2 en cours d'extraction. Résultats wirés automatiquement par Auto-Wire Agent */30.\n";
$wireCtx .= "S88/S89 = ANNULÉS mais snapshots Hetzner conservés pour data mining.]\n";
}
// Inject wire context into system prompt
if ($wireCtx) $sys .= "\n" . $wireCtx;
$body = [["role"=>"system","content"=>$sys],["role"=>"user","content"=>mb_substr($msg,0,50000)]];
$resp = ''; $provider = '';
// Adaptive max_tokens: logos/schemas need more space
$isRich = preg_match('/(logo|schema|mermaid|diagramme|architecture|svg|flowchart|swot|analyse)/i', $msg);
$isCode = preg_match("/(ecris|code|script|function|class|component|api|rest|crud|debug|test|phpunit|jest|vue|react|fastapi|python|rapport.*complet|audit.*complet|compare.*detail|matrice)/i", $msg);
$maxTok = $isCode ? 8000 : ($isRich ? 4000 : 2000);
// ── 1. GROQ (llama-3.3-70b, ~1-3s) ──
$ch = curl_init('https://api.groq.com/openai/v1/chat/completions');
curl_setopt_array($ch, [
CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 15, CURLOPT_CONNECTTIMEOUT => 2,
CURLOPT_HTTPHEADER => ['Content-Type: application/json', 'Authorization: Bearer '.GROQ_KEY],
CURLOPT_POSTFIELDS => json_encode(['model'=>'llama-3.3-70b-versatile','messages'=>$body,'max_tokens'=>$maxTok,'temperature'=>0.7])
]);
$r = curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch);
if ($code == 200 && $r) {
$d = json_decode($r, true);
$t = trim($d['choices'][0]['message']['content'] ?? '');
if (strlen($t) > 20) { $resp = $t; $provider = 'Groq llama-3.3-70b'; }
}
// ── 2. CEREBRAS (llama-3.3-70b, ~2-5s) ──
if (!$resp) {
$ck = (date("i") % 2 == 0) ? CEREBRAS_KEY : CEREBRAS_KEY2;
$ch = curl_init('https://api.cerebras.ai/v1/chat/completions');
curl_setopt_array($ch, [
CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 15, CURLOPT_CONNECTTIMEOUT => 2,
CURLOPT_HTTPHEADER => ['Content-Type: application/json', 'Authorization: Bearer '.$ck],
CURLOPT_POSTFIELDS => json_encode(['model'=>'qwen-3-235b-a22b-instruct-2507','messages'=>$body,'max_tokens'=>$maxTok,'temperature'=>0.7])
]);
$r = curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch);
if ($code == 200 && $r) {
$d = json_decode($r, true);
$t = trim($d['choices'][0]['message']['content'] ?? '');
if (strlen($t) > 20) { $resp = $t; $provider = 'Cerebras Qwen-235B'; }
}
}
// ── 3. SAMBANOVA (fallback) ──
if (!$resp) {
$ch = curl_init('https://api.sambanova.ai/v1/chat/completions');
curl_setopt_array($ch, [
CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 15, CURLOPT_CONNECTTIMEOUT => 2,
CURLOPT_HTTPHEADER => ['Content-Type: application/json', 'Authorization: Bearer '.SAMBANOVA_KEY],
CURLOPT_POSTFIELDS => json_encode(['model'=>'Meta-Llama-3.3-70B-Instruct','messages'=>$body,'max_tokens'=>$maxTok])
]);
$r = curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch);
if ($code == 200 && $r) {
$d = json_decode($r, true);
$t = trim($d['choices'][0]['message']['content'] ?? '');
if (strlen($t) > 20) { $resp = $t; $provider = 'SambaNova Llama-3.3-70B'; }
}
}
// Extra providers: Gemini + CF GPU + NVIDIA NIM + Ollama S204 + OpenRouter + Mistral + Together
@include_once __DIR__.'/weval-providers-extra.php';
// ── 4. S151 GRANITE4 (CPU sovereign fallback) ──
if (!$resp) {
$ch = curl_init('http://151.80.235.110:11434/api/chat');
curl_setopt_array($ch, [
CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 15, CURLOPT_CONNECTTIMEOUT => 3,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'model' => 'qwen3:8b',
'messages' => [['role'=>'system','content'=>$sys],['role'=>'user','content'=>mb_substr($msg,0,50000)]],
'stream' => false, 'think' => false,
'options' => ['num_predict'=>300,'temperature'=>0.7]
])
]);
$r = curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch);
if ($code == 200 && $r) {
$d = json_decode($r, true);
$t = trim($d['message']['content'] ?? '');
if (strlen($t) > 20) { $resp = $t; $provider = 'WEVIA Engine (granite4)'; }
}
}
if (!$resp) { $resp = 'Service temporairement indisponible, veuillez reessayer.'; $provider = 'WEVIA IA'; }
die(json_encode(['response'=>wevia_sanitize_public($resp),'provider'=>'WEVIA Engine','mode'=>$in['mode']??'deep','sources'=>[]]));