$n) if ($n) $lines[] = " · " . $t . ": " . $n; $lines[] = "Tasks pending: " . ($s["tasks_pending"] ?? 0); $lines[] = "Alertes P0: " . ($s["alerts"] ?? 0); $lines[] = "Opportunities: " . ($s["opportunities"] ?? 0); $lines[] = "\nUI: https://weval-consulting.com/wevia-apple.html"; return implode("\n", $lines); } } // apple recommendations if (preg_match('/\b(apple|iphone)\s*(reco|recommand)/iu', $prompt) || preg_match('/recommand.*(apple|iphone)/iu', $prompt)) { $r = @json_decode(@file_get_contents("http://127.0.0.1/api/wevia-apple-ingest.php?action=recommendations"), true); if ($r) { $lines = ["💡 Top recommandations WEVIA Apple (" . ($r["total"] ?? 0) . " total)"]; foreach (array_slice($r["recommendations"] ?? [], 0, 10) as $i => $reco) { $lines[] = ($i+1) . ". [" . $reco["priority"] . "] " . $reco["label"]; $lines[] = " → " . $reco["action"]; } if (empty($r["recommendations"])) $lines[] = "(Aucune reco — ingère du contenu d'abord)"; return implode("\n", $lines); } } // apple alerts if (preg_match('/\b(apple|iphone)\s*(alert|urgent|urgence)/iu', $prompt)) { $a = @json_decode(@file_get_contents("http://127.0.0.1/api/wevia-apple-ingest.php?action=alerts"), true); if ($a) { $lines = ["🚨 Alertes WEVIA Apple (" . count($a["alerts"] ?? []) . ")"]; foreach ($a["alerts"] ?? [] as $al) { $lines[] = "- " . ($al["label"] ?? "") . " → " . ($al["action"] ?? ""); } if (empty($a["alerts"])) $lines[] = "Aucune alerte urgente 👍"; return implode("\n", $lines); } } // apple ingest note if (preg_match('/^(apple\s*note|ingest\s*note|note\s*apple)\s*:?\s*(.+)/iu', $prompt, $m)) { $body = trim($m[2]); if ($body) { $ch = curl_init("http://127.0.0.1/api/wevia-apple-ingest.php?action=ingest_structured"); curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER=>1,CURLOPT_POST=>1, CURLOPT_HTTPHEADER=>["Content-Type: application/json"], CURLOPT_POSTFIELDS=>json_encode(["type"=>"note","items"=>[["title"=>"WEVIA Master ingest","body"=>$body]]])]); $rr = curl_exec($ch); curl_close($ch); $d = @json_decode($rr, true); return "📝 Note ingérée → ID: " . ($d["ids"][0] ?? "?") . " · Analyse IA en cours (entités + reco)"; } } // apple entities if (preg_match('/\b(apple|iphone)\s*(entit|entities)/iu', $prompt)) { $e = @json_decode(@file_get_contents("http://127.0.0.1/api/wevia-apple-ingest.php?action=entities"), true); if ($e) { $lines = ["🔎 Entités extraites WEVIA Apple"]; foreach ($e["entities"] ?? [] as $cat => $list) { if (!empty($list)) { $top = array_slice($list, 0, 5); $vals = array_map(function($x) { return $x["value"] . " (×" . $x["count"] . ")"; }, $top); $lines[] = $cat . " [" . count($list) . "]: " . implode(", ", $vals); } } return implode("\n", $lines); } } // apple tasks if (preg_match('/\b(apple|iphone)\s*(task|tache)/iu', $prompt)) { $t = @json_decode(@file_get_contents("http://127.0.0.1/api/wevia-apple-ingest.php?action=tasks"), true); if ($t) { $lines = ["📋 Tasks WEVIA Apple (" . count($t["tasks"] ?? []) . ")"]; foreach (array_slice($t["tasks"] ?? [], 0, 10) as $task) { $lines[] = "- [" . ($task["priority"] ?? "") . "] " . ($task["label"] ?? "") . " (" . ($task["status"] ?? "open") . ")"; } return implode("\n", $lines); } } // apple setup / iphone setup if (preg_match('/\b(apple|iphone)\s*(setup|install|config|shortcut)/iu', $prompt)) { return "📲 WEVIA Apple v3 Setup\n\n" . "1. Ouvre https://weval-consulting.com/wevia-apple.html sur ton iPhone\n" . "2. Clique '📲 iPhone Setup' en haut à droite\n" . "3. Suis les 3 solutions (iPhone Shortcuts / Automation iCloud / Blade MCP)\n\n" . "Endpoint: https://weval-consulting.com/api/wevia-apple-ingest.php\n" . "7 types supportés: photos, messages, contacts, calendar, notes, calls, health"; } return null; } // Auto-register with the orchestrator if available $__wa_prompt = $_POST['prompt'] ?? $_POST['message'] ?? $_GET['q'] ?? null; if ($__wa_prompt && (defined('WEVIA_APPLE_STANDALONE') || strpos($_SERVER['SCRIPT_NAME'] ?? '', 'wevia-apple-intents') !== false)) { $r = wevia_apple_v3_intents($__wa_prompt); if ($r !== null) { header('Content-Type: application/json'); echo json_encode(["ok"=>true, "response"=>$r, "provider"=>"wevia-apple-v3"]); exit; } }