Files
wevads-platform/scripts/hamid-brain-config.php
2026-02-26 04:53:11 +01:00

659 lines
57 KiB
PHP
Executable File

<?php
# PMTA Hostname Fix Sun Feb 8 00:44:02 CET 2026
session_start();
$pdo = new PDO("pgsql:host=localhost;dbname=adx_system", "admin", "admin123");
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Créer/update table
$pdo->exec("CREATE TABLE IF NOT EXISTS admin.hamid_brain_config (
id SERIAL PRIMARY KEY,
config_key VARCHAR(100) UNIQUE NOT NULL,
config_value TEXT,
category VARCHAR(50) DEFAULT 'general',
subcategory VARCHAR(50) DEFAULT '',
description TEXT,
field_type VARCHAR(20) DEFAULT 'text',
options TEXT DEFAULT '',
placeholder TEXT DEFAULT '',
min_value FLOAT,
max_value FLOAT,
is_required INT DEFAULT 0,
is_advanced INT DEFAULT 0,
is_claude_feature INT DEFAULT 0,
sort_order INT DEFAULT 0,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)");
// Ajouter colonne claude feature si manquante
try { $pdo->exec("ALTER TABLE admin.hamid_brain_config ADD COLUMN IF NOT EXISTS is_claude_feature INT DEFAULT 0"); } catch (Exception $e) {}
// TOUTES les configurations possibles avec features Claude marquées
$defaults = [
// ═══════════════════════════════════════════════════════════════
// IDENTITÉ
// ═══════════════════════════════════════════════════════════════
['bot_name', 'WEVAL MIND', 'identity', 'core', 'Nom du bot', 'text', '', 'Ex: WEVAL MIND, Assistant...', null, null, 1, 0, 0, 1],
['bot_full_name', 'WEVAL MIND - Assistant IA Intelligent', 'identity', 'core', 'Nom complet affiché', 'text', '', '', null, null, 0, 0, 0, 2],
['bot_role', 'Assistant IA Expert WEVAL', 'identity', 'core', 'Rôle principal', 'text', '', '', null, null, 1, 0, 0, 3],
['bot_personality', 'Direct, concis, intelligent, expert technique, style Claude Opus 4.5', 'identity', 'personality', 'Personnalité détaillée', 'textarea', '', '', null, null, 0, 0, 1, 4],
['bot_expertise', 'Email Marketing, PowerMTA, DNS, Linux, PostgreSQL, PHP, Python', 'identity', 'personality', 'Domaines d\'expertise', 'textarea', '', '', null, null, 0, 0, 0, 5],
['bot_avatar', '🧠', 'identity', 'appearance', 'Avatar/Emoji', 'text', '', '', null, null, 0, 0, 0, 6],
['bot_color', '#06b6d4', 'identity', 'appearance', 'Couleur principale', 'color', '', '', null, null, 0, 0, 0, 7],
['bot_secondary_color', '#8b5cf6', 'identity', 'appearance', 'Couleur secondaire', 'color', '', '', null, null, 0, 1, 0, 8],
['bot_greeting', 'Bonjour! Comment puis-je vous aider?', 'identity', 'messages', 'Message d\'accueil', 'text', '', '', null, null, 0, 0, 0, 9],
['bot_error_message', 'Désolé, une erreur est survenue. Réessayez.', 'identity', 'messages', 'Message d\'erreur', 'text', '', '', null, null, 0, 1, 0, 10],
// ═══════════════════════════════════════════════════════════════
// STYLE CLAUDE - TOUTES LES FEATURES CLAUDE MARQUÉES
// ═══════════════════════════════════════════════════════════════
['style_direct', '1', 'style', 'claude_core', '🎯 DIRECT - Va droit au but, pas de préambules', 'checkbox', '', '', null, null, 0, 0, 1, 1],
['style_concis', '1', 'style', 'claude_core', '✂️ CONCIS - Montre les résultats, pas d\'explications inutiles', 'checkbox', '', '', null, null, 0, 0, 1, 2],
['style_no_formules', '1', 'style', 'claude_core', '🚫 PAS DE FORMULES CREUSES - Jamais "N\'hésitez pas"', 'checkbox', '', '', null, null, 0, 0, 1, 3],
['style_assume', '1', 'style', 'claude_core', '💪 ASSUME - Pas de "Je pense que...", "Il semble..."', 'checkbox', '', '', null, null, 0, 0, 1, 4],
['style_no_apologize', '1', 'style', 'claude_core', '🙅 NE S\'EXCUSE PAS - Pas de "Désolé", "Pardon"', 'checkbox', '', '', null, null, 0, 0, 1, 5],
['style_proactive', '1', 'style', 'claude_core', '🚀 PROACTIF - Propose toujours l\'étape suivante', 'checkbox', '', '', null, null, 0, 0, 1, 6],
['style_action_oriented', '1', 'style', 'claude_core', '⚡ ORIENTÉ ACTION - Fait plutôt qu\'explique', 'checkbox', '', '', null, null, 0, 0, 1, 7],
['style_honest', '1', 'style', 'claude_values', '🎯 HONNÊTE - Dit quand il ne sait pas', 'checkbox', '', '', null, null, 0, 0, 1, 8],
['style_helpful', '1', 'style', 'claude_values', '🤝 UTILE - Priorise l\'aide réelle', 'checkbox', '', '', null, null, 0, 0, 1, 9],
['style_harmless', '1', 'style', 'claude_values', '🛡️ SÉCURITAIRE - Évite les contenus nuisibles', 'checkbox', '', '', null, null, 0, 0, 1, 10],
['style_structured', '1', 'style', 'formatting', '📋 STRUCTURÉ - Titres, listes, tableaux', 'checkbox', '', '', null, null, 0, 0, 1, 11],
['style_code_blocks', '1', 'style', 'formatting', '💻 CODE FORMATÉ - Syntax highlighting', 'checkbox', '', '', null, null, 0, 0, 1, 12],
['style_markdown', '1', 'style', 'formatting', '📝 MARKDOWN - Support complet', 'checkbox', '', '', null, null, 0, 0, 0, 13],
['style_latex', '0', 'style', 'formatting', '🔢 LATEX - Formules mathématiques', 'checkbox', '', '', null, null, 0, 1, 0, 14],
['style_tables', '1', 'style', 'formatting', '📊 TABLEAUX - Données tabulaires', 'checkbox', '', '', null, null, 0, 0, 0, 15],
['style_emojis', 'parcimonie', 'style', 'tone', 'Utilisation des emojis', 'select', 'jamais,parcimonie,modéré,souvent,toujours', '', null, null, 0, 0, 0, 16],
['style_language', 'fr', 'style', 'tone', 'Langue par défaut', 'select', 'fr,en,es,de,it,pt,ar,zh,ja,auto', '', null, null, 0, 0, 0, 17],
['style_tone', 'professional', 'style', 'tone', 'Ton de communication', 'select', 'casual,friendly,professional,formal,technical,academic', '', null, null, 0, 0, 0, 18],
['style_verbosity', 'normal', 'style', 'tone', 'Niveau de détail', 'select', 'ultra_concis,minimal,concis,normal,détaillé,exhaustif,verbeux', '', null, null, 0, 0, 0, 19],
['style_formality', 'tu', 'style', 'tone', 'Niveau de formalité', 'select', 'tu,vous,adaptatif', '', null, null, 0, 0, 0, 20],
['style_humor', '0', 'style', 'tone', '😄 Humour occasionnel', 'checkbox', '', '', null, null, 0, 1, 0, 21],
['style_sarcasm', '0', 'style', 'tone', '😏 Sarcasme léger autorisé', 'checkbox', '', '', null, null, 0, 1, 0, 22],
['style_empathy', '1', 'style', 'tone', '💝 Empathie et compréhension', 'checkbox', '', '', null, null, 0, 0, 0, 23],
['style_enthusiasm', '1', 'style', 'tone', '🎉 Enthousiasme mesuré', 'checkbox', '', '', null, null, 0, 0, 0, 24],
['style_technical_level', 'expert', 'style', 'adaptation', 'Niveau technique par défaut', 'select', 'débutant,intermédiaire,avancé,expert,génie', '', null, null, 0, 0, 0, 25],
['style_adapt_user', '1', 'style', 'adaptation', '🎭 S\'adapter au niveau utilisateur', 'checkbox', '', '', null, null, 0, 0, 1, 26],
['style_explain_code', '0', 'style', 'adaptation', '📖 Expliquer le code automatiquement', 'checkbox', '', '', null, null, 0, 0, 0, 27],
['style_show_reasoning', '0', 'style', 'adaptation', '🧠 Montrer le raisonnement', 'checkbox', '', '', null, null, 0, 0, 0, 28],
// ═══════════════════════════════════════════════════════════════
// CAPACITÉS - ULTRA ENRICHIES
// ═══════════════════════════════════════════════════════════════
// Exécution de code
['cap_bash', '1', 'capabilities', 'execution', '🖥️ Bash/Shell - Commandes système', 'checkbox', '', '', null, null, 0, 0, 1, 1],
['cap_python', '1', 'capabilities', 'execution', '🐍 Python - Scripts et analyse', 'checkbox', '', '', null, null, 0, 0, 1, 2],
['cap_python_packages', 'pandas,numpy,requests,beautifulsoup4,matplotlib', 'capabilities', 'execution', 'Packages Python autorisés', 'text', '', '', null, null, 0, 1, 0, 3],
['cap_php', '1', 'capabilities', 'execution', '🐘 PHP - Scripts web', 'checkbox', '', '', null, null, 0, 0, 1, 4],
['cap_sql', '1', 'capabilities', 'execution', '🗃️ SQL - PostgreSQL/MySQL', 'checkbox', '', '', null, null, 0, 0, 1, 5],
['cap_javascript', '1', 'capabilities', 'execution', '📜 JavaScript/Node.js', 'checkbox', '', '', null, null, 0, 0, 1, 6],
['cap_typescript', '0', 'capabilities', 'execution', '📘 TypeScript', 'checkbox', '', '', null, null, 0, 1, 0, 7],
['cap_ruby', '0', 'capabilities', 'execution', '💎 Ruby', 'checkbox', '', '', null, null, 0, 1, 0, 8],
['cap_go', '0', 'capabilities', 'execution', '🐹 Go/Golang', 'checkbox', '', '', null, null, 0, 1, 0, 9],
['cap_rust', '0', 'capabilities', 'execution', '🦀 Rust', 'checkbox', '', '', null, null, 0, 1, 0, 10],
['cap_java', '0', 'capabilities', 'execution', '☕ Java', 'checkbox', '', '', null, null, 0, 1, 0, 11],
['cap_csharp', '0', 'capabilities', 'execution', '🎯 C#/.NET', 'checkbox', '', '', null, null, 0, 1, 0, 12],
['cap_cpp', '0', 'capabilities', 'execution', '⚙️ C/C++', 'checkbox', '', '', null, null, 0, 1, 0, 13],
['cap_perl', '0', 'capabilities', 'execution', '🐪 Perl', 'checkbox', '', '', null, null, 0, 1, 0, 14],
['cap_r', '0', 'capabilities', 'execution', '📊 R (statistiques)', 'checkbox', '', '', null, null, 0, 1, 0, 15],
// Fichiers
['cap_files_read', '1', 'capabilities', 'files', '📖 Lecture de fichiers', 'checkbox', '', '', null, null, 0, 0, 1, 20],
['cap_files_write', '1', 'capabilities', 'files', '✏️ Écriture/création fichiers', 'checkbox', '', '', null, null, 0, 0, 1, 21],
['cap_files_edit', '1', 'capabilities', 'files', '🔧 Modification fichiers existants', 'checkbox', '', '', null, null, 0, 0, 1, 22],
['cap_files_delete', '0', 'capabilities', 'files', '🗑️ Suppression fichiers (dangereux)', 'checkbox', '', '', null, null, 0, 1, 0, 23],
['cap_files_move', '1', 'capabilities', 'files', '📁 Déplacer/renommer fichiers', 'checkbox', '', '', null, null, 0, 0, 0, 24],
['cap_files_compress', '1', 'capabilities', 'files', '📦 Compression/décompression', 'checkbox', '', '', null, null, 0, 0, 0, 25],
['cap_files_search', '1', 'capabilities', 'files', '🔍 Recherche dans fichiers', 'checkbox', '', '', null, null, 0, 0, 1, 26],
['cap_files_diff', '1', 'capabilities', 'files', '📊 Comparaison de fichiers (diff)', 'checkbox', '', '', null, null, 0, 0, 0, 27],
// Analyse documents
['cap_ocr', '1', 'capabilities', 'analysis', '👁️ OCR - Extraction texte images', 'checkbox', '', '', null, null, 0, 0, 1, 30],
['cap_pdf_read', '1', 'capabilities', 'analysis', '📕 Lecture PDF', 'checkbox', '', '', null, null, 0, 0, 1, 31],
['cap_pdf_create', '1', 'capabilities', 'analysis', '📕 Création PDF', 'checkbox', '', '', null, null, 0, 0, 0, 32],
['cap_pdf_edit', '0', 'capabilities', 'analysis', '📕 Modification PDF', 'checkbox', '', '', null, null, 0, 1, 0, 33],
['cap_docx_read', '1', 'capabilities', 'analysis', '📘 Lecture Word/DOCX', 'checkbox', '', '', null, null, 0, 0, 1, 34],
['cap_docx_create', '1', 'capabilities', 'analysis', '📘 Création Word/DOCX', 'checkbox', '', '', null, null, 0, 0, 0, 35],
['cap_xlsx_read', '1', 'capabilities', 'analysis', '📗 Lecture Excel/XLSX', 'checkbox', '', '', null, null, 0, 0, 1, 36],
['cap_xlsx_create', '1', 'capabilities', 'analysis', '📗 Création Excel/XLSX', 'checkbox', '', '', null, null, 0, 0, 0, 37],
['cap_pptx', '0', 'capabilities', 'analysis', '📙 PowerPoint/PPTX', 'checkbox', '', '', null, null, 0, 1, 0, 38],
['cap_csv', '1', 'capabilities', 'analysis', '📊 CSV/TSV', 'checkbox', '', '', null, null, 0, 0, 1, 39],
['cap_json', '1', 'capabilities', 'analysis', '📋 JSON/YAML', 'checkbox', '', '', null, null, 0, 0, 1, 40],
['cap_xml', '1', 'capabilities', 'analysis', '📜 XML/HTML', 'checkbox', '', '', null, null, 0, 0, 0, 41],
['cap_markdown', '1', 'capabilities', 'analysis', '📝 Markdown', 'checkbox', '', '', null, null, 0, 0, 1, 42],
// Images
['cap_image_view', '1', 'capabilities', 'images', '🖼️ Visualisation images', 'checkbox', '', '', null, null, 0, 0, 1, 45],
['cap_image_analyze', '1', 'capabilities', 'images', '🔍 Analyse/description images', 'checkbox', '', '', null, null, 0, 0, 1, 46],
['cap_image_edit', '0', 'capabilities', 'images', '✏️ Édition images basique', 'checkbox', '', '', null, null, 0, 1, 0, 47],
['cap_image_generate', '0', 'capabilities', 'images', '🎨 Génération images IA', 'checkbox', '', '', null, null, 0, 1, 0, 48],
['cap_image_convert', '1', 'capabilities', 'images', '🔄 Conversion formats images', 'checkbox', '', '', null, null, 0, 0, 0, 49],
['cap_image_resize', '1', 'capabilities', 'images', '📐 Redimensionnement images', 'checkbox', '', '', null, null, 0, 0, 0, 50],
['cap_screenshot', '0', 'capabilities', 'images', '📸 Capture d\'écran', 'checkbox', '', '', null, null, 0, 1, 0, 51],
// Audio/Video
['cap_audio_transcribe', '0', 'capabilities', 'media', '🎙️ Transcription audio', 'checkbox', '', '', null, null, 0, 1, 0, 55],
['cap_audio_analyze', '0', 'capabilities', 'media', '🔊 Analyse audio', 'checkbox', '', '', null, null, 0, 1, 0, 56],
['cap_video_analyze', '0', 'capabilities', 'media', '🎬 Analyse vidéo', 'checkbox', '', '', null, null, 0, 1, 0, 57],
['cap_tts', '0', 'capabilities', 'media', '🗣️ Text-to-Speech', 'checkbox', '', '', null, null, 0, 1, 0, 58],
// Web & Réseau
['cap_web_fetch', '1', 'capabilities', 'web', '🌐 Requêtes HTTP/API', 'checkbox', '', '', null, null, 0, 0, 1, 60],
['cap_web_scrape', '1', 'capabilities', 'web', '🕷️ Web scraping', 'checkbox', '', '', null, null, 0, 0, 0, 61],
['cap_web_search', '0', 'capabilities', 'web', '🔍 Recherche web', 'checkbox', '', '', null, null, 0, 1, 0, 62],
['cap_api_rest', '1', 'capabilities', 'web', '🔌 APIs REST', 'checkbox', '', '', null, null, 0, 0, 1, 63],
['cap_api_graphql', '0', 'capabilities', 'web', '📊 APIs GraphQL', 'checkbox', '', '', null, null, 0, 1, 0, 64],
['cap_websocket', '0', 'capabilities', 'web', '🔗 WebSocket', 'checkbox', '', '', null, null, 0, 1, 0, 65],
['cap_ftp', '0', 'capabilities', 'web', '📁 FTP/SFTP', 'checkbox', '', '', null, null, 0, 1, 0, 66],
['cap_ssh', '1', 'capabilities', 'web', '🔐 SSH/SCP', 'checkbox', '', '', null, null, 0, 0, 0, 67],
// Domaines d\'expertise
['cap_email_smtp', '1', 'capabilities', 'domain', '📧 Email/SMTP', 'checkbox', '', '', null, null, 0, 0, 0, 70],
['cap_email_powermta', '1', 'capabilities', 'domain', '⚡ PowerMTA', 'checkbox', '', '', null, null, 0, 0, 0, 71],
['cap_email_deliverability', '1', 'capabilities', 'domain', '📬 Délivrabilité email', 'checkbox', '', '', null, null, 0, 0, 0, 72],
['cap_dns', '1', 'capabilities', 'domain', '🌍 DNS/Domaines', 'checkbox', '', '', null, null, 0, 0, 0, 73],
['cap_ssl', '1', 'capabilities', 'domain', '🔒 SSL/TLS/Certificats', 'checkbox', '', '', null, null, 0, 0, 0, 74],
['cap_server_linux', '1', 'capabilities', 'domain', '🐧 Administration Linux', 'checkbox', '', '', null, null, 0, 0, 0, 75],
['cap_server_nginx', '1', 'capabilities', 'domain', '🌐 Nginx/Apache', 'checkbox', '', '', null, null, 0, 0, 0, 76],
['cap_docker', '1', 'capabilities', 'domain', '🐳 Docker/Containers', 'checkbox', '', '', null, null, 0, 0, 0, 77],
['cap_kubernetes', '0', 'capabilities', 'domain', '☸️ Kubernetes', 'checkbox', '', '', null, null, 0, 1, 0, 78],
['cap_git', '1', 'capabilities', 'domain', '📚 Git/Versioning', 'checkbox', '', '', null, null, 0, 0, 0, 79],
['cap_ci_cd', '0', 'capabilities', 'domain', '🔄 CI/CD', 'checkbox', '', '', null, null, 0, 1, 0, 80],
['cap_cloud_aws', '0', 'capabilities', 'domain', '☁️ AWS', 'checkbox', '', '', null, null, 0, 1, 0, 81],
['cap_cloud_gcp', '0', 'capabilities', 'domain', '☁️ Google Cloud', 'checkbox', '', '', null, null, 0, 1, 0, 82],
['cap_cloud_azure', '0', 'capabilities', 'domain', '☁️ Azure', 'checkbox', '', '', null, null, 0, 1, 0, 83],
['cap_database_postgres', '1', 'capabilities', 'domain', '🐘 PostgreSQL', 'checkbox', '', '', null, null, 0, 0, 0, 84],
['cap_database_mysql', '1', 'capabilities', 'domain', '🐬 MySQL/MariaDB', 'checkbox', '', '', null, null, 0, 0, 0, 85],
['cap_database_redis', '0', 'capabilities', 'domain', '🔴 Redis', 'checkbox', '', '', null, null, 0, 1, 0, 86],
['cap_database_mongo', '0', 'capabilities', 'domain', '🍃 MongoDB', 'checkbox', '', '', null, null, 0, 1, 0, 87],
// ═══════════════════════════════════════════════════════════════
// ARTIFACTS - FEATURES CLAUDE
// ═══════════════════════════════════════════════════════════════
['artifact_enabled', '1', 'artifacts', 'core', '🎨 Système Artifacts activé', 'checkbox', '', '', null, null, 0, 0, 1, 1],
['artifact_auto_preview', '1', 'artifacts', 'core', '👁️ Preview automatique', 'checkbox', '', '', null, null, 0, 0, 1, 2],
['artifact_auto_download', '0', 'artifacts', 'core', '📥 Téléchargement auto', 'checkbox', '', '', null, null, 0, 1, 0, 3],
['artifact_html', '1', 'artifacts', 'types', '🌐 HTML - Pages web complètes', 'checkbox', '', '', null, null, 0, 0, 1, 10],
['artifact_react', '1', 'artifacts', 'types', '⚛️ React/JSX - Composants interactifs', 'checkbox', '', '', null, null, 0, 0, 1, 11],
['artifact_vue', '0', 'artifacts', 'types', '💚 Vue.js', 'checkbox', '', '', null, null, 0, 1, 0, 12],
['artifact_svelte', '0', 'artifacts', 'types', '🔥 Svelte', 'checkbox', '', '', null, null, 0, 1, 0, 13],
['artifact_svg', '1', 'artifacts', 'types', '🎨 SVG - Graphiques vectoriels', 'checkbox', '', '', null, null, 0, 0, 1, 14],
['artifact_canvas', '0', 'artifacts', 'types', '🖼️ Canvas interactif', 'checkbox', '', '', null, null, 0, 1, 0, 15],
['artifact_mermaid', '1', 'artifacts', 'types', '📊 Mermaid - Diagrammes', 'checkbox', '', '', null, null, 0, 0, 1, 16],
['artifact_plantuml', '0', 'artifacts', 'types', '📐 PlantUML', 'checkbox', '', '', null, null, 0, 1, 0, 17],
['artifact_d3', '0', 'artifacts', 'types', '📈 D3.js - Visualisations', 'checkbox', '', '', null, null, 0, 1, 0, 18],
['artifact_chartjs', '0', 'artifacts', 'types', '📊 Chart.js', 'checkbox', '', '', null, null, 0, 1, 0, 19],
['artifact_markdown', '1', 'artifacts', 'types', '📝 Markdown', 'checkbox', '', '', null, null, 0, 0, 1, 20],
['artifact_latex', '0', 'artifacts', 'types', '🔢 LaTeX', 'checkbox', '', '', null, null, 0, 1, 0, 21],
['artifact_csv', '1', 'artifacts', 'types', '📊 CSV/JSON export', 'checkbox', '', '', null, null, 0, 0, 1, 22],
['artifact_pdf', '1', 'artifacts', 'types', '📕 PDF', 'checkbox', '', '', null, null, 0, 0, 0, 23],
['artifact_docx', '1', 'artifacts', 'types', '📘 Word DOCX', 'checkbox', '', '', null, null, 0, 0, 0, 24],
['artifact_xlsx', '1', 'artifacts', 'types', '📗 Excel XLSX', 'checkbox', '', '', null, null, 0, 0, 0, 25],
['artifact_code', '1', 'artifacts', 'types', '💻 Fichiers code', 'checkbox', '', '', null, null, 0, 0, 1, 26],
['artifact_max_size', '5000000', 'artifacts', 'limits', 'Taille max (bytes)', 'number', '', '', 1000, 50000000, 0, 1, 0, 30],
['artifact_retention', '30', 'artifacts', 'limits', 'Rétention (jours)', 'number', '', '', 1, 365, 0, 1, 0, 31],
// ═══════════════════════════════════════════════════════════════
// THINKING & RAISONNEMENT - FEATURES CLAUDE
// ═══════════════════════════════════════════════════════════════
['thinking_enabled', '1', 'thinking', 'core', '🧠 Mode réflexion activé', 'checkbox', '', '', null, null, 0, 0, 1, 1],
['thinking_visible', '0', 'thinking', 'display', '👁️ Afficher le processus de réflexion', 'checkbox', '', '', null, null, 0, 0, 0, 2],
['thinking_expandable', '0', 'thinking', 'display', '📂 Réflexion repliable/dépliable', 'checkbox', '', '', null, null, 0, 1, 0, 3],
['thinking_step_by_step', '1', 'thinking', 'methods', '📝 Raisonnement étape par étape', 'checkbox', '', '', null, null, 0, 0, 1, 10],
['thinking_chain_of_thought', '1', 'thinking', 'methods', '🔗 Chain of Thought', 'checkbox', '', '', null, null, 0, 0, 1, 11],
['thinking_tree_of_thought', '0', 'thinking', 'methods', '🌳 Tree of Thought', 'checkbox', '', '', null, null, 0, 1, 0, 12],
['thinking_self_critique', '1', 'thinking', 'methods', '🔍 Auto-critique', 'checkbox', '', '', null, null, 0, 0, 1, 13],
['thinking_self_correction', '1', 'thinking', 'methods', '✏️ Auto-correction', 'checkbox', '', '', null, null, 0, 0, 1, 14],
['thinking_decomposition', '1', 'thinking', 'methods', '🧩 Décomposition problèmes', 'checkbox', '', '', null, null, 0, 0, 1, 15],
['thinking_analogies', '1', 'thinking', 'methods', '🔄 Utiliser des analogies', 'checkbox', '', '', null, null, 0, 0, 0, 16],
['thinking_show_sources', '1', 'thinking', 'transparency', '📚 Citer les sources', 'checkbox', '', '', null, null, 0, 0, 1, 20],
['thinking_uncertainty', '1', 'thinking', 'transparency', '❓ Exprimer l\'incertitude', 'checkbox', '', '', null, null, 0, 0, 1, 21],
['thinking_confidence', '0', 'thinking', 'transparency', '📊 Afficher niveau de confiance', 'checkbox', '', '', null, null, 0, 1, 0, 22],
['thinking_limitations', '1', 'thinking', 'transparency', '⚠️ Mentionner les limitations', 'checkbox', '', '', null, null, 0, 0, 1, 23],
['thinking_alternatives', '1', 'thinking', 'output', '🔀 Proposer des alternatives', 'checkbox', '', '', null, null, 0, 0, 1, 30],
['thinking_pros_cons', '1', 'thinking', 'output', '⚖️ Analyser avantages/inconvénients', 'checkbox', '', '', null, null, 0, 0, 1, 31],
['thinking_examples', '1', 'thinking', 'output', '💡 Donner des exemples', 'checkbox', '', '', null, null, 0, 0, 1, 32],
['thinking_counterarguments', '0', 'thinking', 'output', '🎭 Présenter contre-arguments', 'checkbox', '', '', null, null, 0, 1, 0, 33],
// ═══════════════════════════════════════════════════════════════
// SÉCURITÉ
// ═══════════════════════════════════════════════════════════════
['safety_enabled', '1', 'safety', 'core', '🛡️ Système de sécurité activé', 'checkbox', '', '', null, null, 1, 0, 1, 1],
['safety_filter_harmful', '1', 'safety', 'filters', '🚫 Filtrer contenu nuisible', 'checkbox', '', '', null, null, 0, 0, 1, 10],
['safety_filter_adult', '1', 'safety', 'filters', '🔞 Filtrer contenu adulte', 'checkbox', '', '', null, null, 0, 0, 0, 11],
['safety_filter_violence', '1', 'safety', 'filters', '⚔️ Filtrer violence', 'checkbox', '', '', null, null, 0, 0, 0, 12],
['safety_filter_illegal', '1', 'safety', 'filters', '⚖️ Filtrer contenu illégal', 'checkbox', '', '', null, null, 0, 0, 1, 13],
['safety_code_review', '1', 'safety', 'code', '🔍 Review code dangereux', 'checkbox', '', '', null, null, 0, 0, 1, 20],
['safety_confirm_delete', '1', 'safety', 'code', '⚠️ Confirmer suppressions', 'checkbox', '', '', null, null, 0, 0, 1, 21],
['safety_confirm_system', '1', 'safety', 'code', '⚠️ Confirmer commandes système', 'checkbox', '', '', null, null, 0, 0, 1, 22],
['safety_confirm_network', '0', 'safety', 'code', '⚠️ Confirmer accès réseau', 'checkbox', '', '', null, null, 0, 1, 0, 23],
['safety_sandbox', '0', 'safety', 'code', '📦 Mode sandbox', 'checkbox', '', '', null, null, 0, 1, 0, 24],
['safety_dry_run', '0', 'safety', 'code', '🧪 Mode simulation', 'checkbox', '', '', null, null, 0, 1, 0, 25],
['safety_max_file_size', '50', 'safety', 'limits', 'Taille max fichier (MB)', 'number', '', '', 1, 500, 0, 0, 0, 30],
['safety_max_output', '500000', 'safety', 'limits', 'Taille max output (chars)', 'number', '', '', 1000, 10000000, 0, 1, 0, 31],
['safety_timeout_cmd', '60', 'safety', 'limits', 'Timeout commandes (sec)', 'number', '', '', 5, 600, 0, 0, 0, 32],
['safety_max_recursion', '10', 'safety', 'limits', 'Profondeur récursion max', 'number', '', '', 1, 50, 0, 1, 0, 33],
['safety_allowed_paths', '/opt/wevads,/home,/tmp,/var/log,/var/www', 'safety', 'paths', 'Chemins autorisés', 'textarea', '', '', null, null, 0, 0, 0, 40],
['safety_blocked_paths', '/etc/shadow,/root/.ssh,/etc/passwd', 'safety', 'paths', 'Chemins bloqués', 'textarea', '', '', null, null, 0, 0, 0, 41],
['safety_blocked_cmds', 'rm -rf /,mkfs,dd if=/dev,:(){ :|:& };:,chmod 777 /,shutdown,reboot', 'safety', 'commands', 'Commandes bloquées', 'textarea', '', '', null, null, 0, 0, 0, 42],
['safety_allowed_domains', '', 'safety', 'network', 'Domaines autorisés (vide=tous)', 'textarea', '', '', null, null, 0, 1, 0, 43],
['safety_blocked_domains', '', 'safety', 'network', 'Domaines bloqués', 'textarea', '', '', null, null, 0, 1, 0, 44],
// ═══════════════════════════════════════════════════════════════
// CONTEXTE
// ═══════════════════════════════════════════════════════════════
['ctx_server_ip', '89.167.40.150', 'context', 'server', 'IP du serveur', 'text', '', '', null, null, 1, 0, 0, 1],
['ctx_server_name', 'WEVAL', 'context', 'server', 'Nom du serveur', 'text', '', '', null, null, 0, 0, 0, 2],
['ctx_server_port', '5821', 'context', 'server', 'Port application', 'number', '', '', 1, 65535, 0, 0, 0, 3],
['ctx_server_os', 'Ubuntu 24.04 LTS', 'context', 'server', 'Système d\'exploitation', 'text', '', '', null, null, 0, 1, 0, 4],
['ctx_server_timezone', 'Europe/Paris', 'context', 'server', 'Fuseau horaire', 'text', '', '', null, null, 0, 1, 0, 5],
['ctx_working_dir', '/opt/wevads/public/', 'context', 'paths', 'Répertoire de travail', 'text', '', '', null, null, 0, 0, 0, 10],
['ctx_temp_dir', '/tmp/hamid/', 'context', 'paths', 'Répertoire temporaire', 'text', '', '', null, null, 0, 1, 0, 11],
['ctx_log_dir', '/var/log/hamid/', 'context', 'paths', 'Répertoire logs', 'text', '', '', null, null, 0, 1, 0, 12],
['ctx_backup_dir', '/opt/backups/', 'context', 'paths', 'Répertoire backups', 'text', '', '', null, null, 0, 1, 0, 13],
['ctx_db_host', 'localhost', 'context', 'database', 'Hôte BDD', 'text', '', '', null, null, 0, 0, 0, 20],
['ctx_db_port', '5432', 'context', 'database', 'Port BDD', 'number', '', '', 1, 65535, 0, 0, 0, 21],
['ctx_db_name', 'adx_system', 'context', 'database', 'Nom BDD', 'text', '', '', null, null, 0, 0, 0, 22],
['ctx_db_schema', 'admin', 'context', 'database', 'Schéma', 'text', '', '', null, null, 0, 0, 0, 23],
['ctx_db_user', 'admin', 'context', 'database', 'Utilisateur BDD', 'text', '', '', null, null, 0, 0, 0, 24],
// ═══════════════════════════════════════════════════════════════
// PARAMÈTRES IA
// ═══════════════════════════════════════════════════════════════
['ai_temperature', '0.1', 'ai_params', 'generation', 'Température (0=déterministe, 1=créatif)', 'range', '0,1,0.05', '', 0, 1, 0, 0, 0, 1],
['ai_top_p', '0.9', 'ai_params', 'generation', 'Top P (nucleus sampling)', 'range', '0,1,0.05', '', 0, 1, 0, 1, 0, 2],
['ai_top_k', '40', 'ai_params', 'generation', 'Top K', 'number', '', '', 1, 100, 0, 1, 0, 3],
['ai_frequency_penalty', '0', 'ai_params', 'generation', 'Pénalité fréquence', 'range', '0,2,0.1', '', 0, 2, 0, 1, 0, 4],
['ai_presence_penalty', '0', 'ai_params', 'generation', 'Pénalité présence', 'range', '0,2,0.1', '', 0, 2, 0, 1, 0, 5],
['ai_repetition_penalty', '1', 'ai_params', 'generation', 'Pénalité répétition', 'range', '0,2,0.1', '', 0, 2, 0, 1, 0, 6],
['ai_max_tokens', '4096', 'ai_params', 'limits', 'Max tokens réponse', 'number', '', '', 100, 128000, 0, 0, 0, 10],
['ai_context_window', '16000', 'ai_params', 'limits', 'Fenêtre contexte', 'number', '', '', 1024, 200000, 0, 1, 0, 11],
['ai_timeout', '120', 'ai_params', 'limits', 'Timeout (sec)', 'number', '', '', 10, 600, 0, 0, 0, 12],
['ai_retry_count', '3', 'ai_params', 'reliability', 'Nombre retry', 'number', '', '', 0, 10, 0, 0, 0, 20],
['ai_retry_delay', '2000', 'ai_params', 'reliability', 'Délai retry (ms)', 'number', '', '', 100, 30000, 0, 1, 0, 21],
['ai_fallback_enabled', '1', 'ai_params', 'reliability', '🔄 Auto-fallback providers', 'checkbox', '', '', null, null, 0, 0, 1, 22],
['ai_fallback_order', 'groq,deepseek,ollama,gemini', 'ai_params', 'reliability', 'Ordre fallback', 'text', '', '', null, null, 0, 0, 0, 23],
['ai_stream', '0', 'ai_params', 'output', '⚡ Streaming réponses', 'checkbox', '', '', null, null, 0, 1, 0, 30],
['ai_json_mode', '0', 'ai_params', 'output', '📋 Mode JSON structuré', 'checkbox', '', '', null, null, 0, 1, 0, 31],
['ai_memory_enabled', '1', 'ai_params', 'memory', '🧠 Mémoire conversation', 'checkbox', '', '', null, null, 0, 0, 1, 40],
['ai_memory_limit', '30', 'ai_params', 'memory', 'Messages en mémoire', 'number', '', '', 1, 100, 0, 0, 0, 41],
['ai_memory_summary', '0', 'ai_params', 'memory', '📝 Résumer anciennes conv', 'checkbox', '', '', null, null, 0, 1, 0, 42],
['ai_memory_persistent', '0', 'ai_params', 'memory', '💾 Mémoire persistante', 'checkbox', '', '', null, null, 0, 1, 0, 43],
// ═══════════════════════════════════════════════════════════════
// KNOWLEDGE BASE
// ═══════════════════════════════════════════════════════════════
['kb_enabled', '1', 'knowledge', 'core', '📚 Knowledge Base activée', 'checkbox', '', '', null, null, 0, 0, 0, 1],
['kb_auto_search', '1', 'knowledge', 'search', '🔍 Recherche automatique', 'checkbox', '', '', null, null, 0, 0, 0, 10],
['kb_semantic_search', '0', 'knowledge', 'search', '🧠 Recherche sémantique', 'checkbox', '', '', null, null, 0, 1, 0, 11],
['kb_max_results', '5', 'knowledge', 'search', 'Résultats max', 'number', '', '', 1, 20, 0, 0, 0, 12],
['kb_min_score', '0.5', 'knowledge', 'search', 'Score minimum', 'range', '0,1,0.1', '', 0, 1, 0, 0, 0, 13],
['kb_include_context', '1', 'knowledge', 'output', '📋 Inclure contexte KB', 'checkbox', '', '', null, null, 0, 0, 0, 20],
['kb_cite_sources', '1', 'knowledge', 'output', '📚 Citer sources KB', 'checkbox', '', '', null, null, 0, 0, 0, 21],
['kb_auto_learn', '0', 'knowledge', 'learning', '🎓 Apprentissage auto', 'checkbox', '', '', null, null, 0, 1, 0, 30],
['kb_learn_threshold', '0.8', 'knowledge', 'learning', 'Seuil apprentissage', 'range', '0,1,0.1', '', 0, 1, 0, 1, 0, 31],
['kb_user_feedback', '0', 'knowledge', 'learning', '👍 Feedback utilisateur', 'checkbox', '', '', null, null, 0, 1, 0, 32],
// ═══════════════════════════════════════════════════════════════
// PROMPTS
// ═══════════════════════════════════════════════════════════════
['prompt_system', '', 'prompts', 'main', 'System Prompt custom (remplace tout)', 'textarea', '', '', null, null, 0, 0, 0, 1],
['prompt_prefix', '', 'prompts', 'modifiers', 'Préfixe (début de chaque prompt)', 'textarea', '', '', null, null, 0, 0, 0, 10],
['prompt_suffix', '', 'prompts', 'modifiers', 'Suffixe (fin de chaque prompt)', 'textarea', '', '', null, null, 0, 0, 0, 11],
['prompt_instructions', '', 'prompts', 'special', 'Instructions spéciales', 'textarea', '', '', null, null, 0, 0, 0, 20],
['prompt_persona', '', 'prompts', 'special', 'Persona spécifique', 'textarea', '', '', null, null, 0, 1, 0, 21],
['prompt_context', '', 'prompts', 'special', 'Contexte additionnel', 'textarea', '', '', null, null, 0, 0, 0, 22],
['prompt_examples', '', 'prompts', 'fewshot', 'Exemples (few-shot)', 'textarea', '', '', null, null, 0, 1, 0, 30],
['prompt_negative', '', 'prompts', 'constraints', 'Instructions négatives (NE PAS faire)', 'textarea', '', '', null, null, 0, 0, 0, 40],
['prompt_format', '', 'prompts', 'constraints', 'Format de sortie souhaité', 'textarea', '', '', null, null, 0, 1, 0, 41],
];
foreach ($defaults as $d) {
$stmt = $pdo->prepare("INSERT INTO admin.hamid_brain_config
(config_key, config_value, category, subcategory, description, field_type, options, placeholder, min_value, max_value, is_required, is_advanced, is_claude_feature, sort_order)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
ON CONFLICT (config_key) DO UPDATE SET
description = EXCLUDED.description, field_type = EXCLUDED.field_type, options = EXCLUDED.options,
placeholder = EXCLUDED.placeholder, subcategory = EXCLUDED.subcategory,
is_claude_feature = EXCLUDED.is_claude_feature, sort_order = EXCLUDED.sort_order");
$stmt->execute($d);
}
// Actions
$message = '';
$msgType = 'success';
if ($_POST['save'] ?? false) {
foreach ($_POST['cfg'] ?? [] as $key => $value) {
$pdo->prepare("UPDATE admin.hamid_brain_config SET config_value=?, updated_at=NOW() WHERE config_key=?")->execute([$value, $key]);
}
$message = '✅ Configuration sauvegardée!';
}
if ($_POST['add_config'] ?? false) {
$key = preg_replace('/[^a-z0-9_]/', '_', strtolower($_POST['new_key'] ?? ''));
if ($key && strlen($key) >= 3) {
try {
$stmt = $pdo->prepare("INSERT INTO admin.hamid_brain_config (config_key, config_value, category, subcategory, description, field_type, options, is_advanced, is_claude_feature) VALUES (?, ?, ?, ?, ?, ?, ?, 1, ?)");
$stmt->execute([$key, $_POST['new_value'] ?? '', $_POST['new_category'] ?? 'custom', $_POST['new_subcategory'] ?? '', $_POST['new_description'] ?? $key, $_POST['new_type'] ?? 'text', $_POST['new_options'] ?? '', ($_POST['new_claude'] ?? 0) ? 1 : 0]);
$message = "✅ '$key' ajouté!";
} catch (Exception $e) { $message = "❌ Clé déjà existante"; $msgType = 'error'; }
}
}
if ($_GET['delete'] ?? false) {
$pdo->prepare("DELETE FROM admin.hamid_brain_config WHERE config_key = ? AND is_required = 0")->execute([$_GET['delete']]);
header("Location: ?msg=deleted"); exit;
}
if ($_GET['export'] ?? false) {
header('Content-Type: application/json');
header('Content-Disposition: attachment; filename="hamid-config-'.date('Y-m-d').'.json"');
echo json_encode($pdo->query("SELECT * FROM admin.hamid_brain_config ORDER BY category, sort_order")->fetchAll(PDO::FETCH_ASSOC), JSON_PRETTY_PRINT);
exit;
}
$configs = [];
$stmt = $pdo->query("SELECT * FROM admin.hamid_brain_config ORDER BY category, sort_order, id");
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) $configs[$row['category']][$row['subcategory'] ?: 'main'][] = $row;
$showAdvanced = isset($_GET['advanced']) || isset($_COOKIE['show_advanced']);
// Prompt generator (comme avant mais optimisé)
function generatePrompt($pdo) {
$cfg = [];
foreach ($pdo->query("SELECT config_key, config_value FROM admin.hamid_brain_config")->fetchAll(PDO::FETCH_ASSOC) as $r) $cfg[$r['config_key']] = $r['config_value'];
if (!empty($cfg['prompt_system'])) return $cfg['prompt_system'];
$p = "Tu es {$cfg['bot_name']}, {$cfg['bot_role']}.\n";
if (!empty($cfg['bot_expertise'])) $p .= "Expertise: {$cfg['bot_expertise']}\n";
$p .= "\n<style>\n";
$rules = [];
if (($cfg['style_direct'] ?? '')=='1') $rules[] = "DIRECT - Va droit au but";
if (($cfg['style_concis'] ?? '')=='1') $rules[] = "CONCIS - Résultats, pas d'explications inutiles";
if (($cfg['style_no_formules'] ?? '')=='1') $rules[] = "PAS DE FORMULES CREUSES";
if (($cfg['style_assume'] ?? '')=='1') $rules[] = "ASSUME - Pas de \"Je pense...\"";
if (($cfg['style_no_apologize'] ?? '')=='1') $rules[] = "NE S'EXCUSE PAS";
if (($cfg['style_proactive'] ?? '')=='1') $rules[] = "PROACTIF - Propose la suite";
if (($cfg['style_action_oriented'] ?? '')=='1') $rules[] = "ORIENTÉ ACTION";
foreach ($rules as $i=>$r) $p .= ($i+1).". $r\n";
$p .= "</style>\n\n";
$caps = [];
foreach ($cfg as $k=>$v) if (strpos($k,'cap_')===0 && $v=='1') $caps[] = str_replace(['cap_','_'],['',' '], $k);
if ($caps) $p .= "<capacités>\n".implode(', ',$caps)."\n</capacités>\n\n";
$p .= "<contexte>\nServeur: ".($cfg['ctx_server_name']??'')."/".($cfg['ctx_server_ip']??'')."\n</contexte>\n";
if (!empty($cfg['prompt_instructions'])) $p .= "\n<instructions>\n{$cfg['prompt_instructions']}\n</instructions>\n";
return $p;
}
$prompt = generatePrompt($pdo);
$categories = [
'identity' => ['icon'=>'fa-user-circle','name'=>'Identité','color'=>'#06b6d4'],
'style' => ['icon'=>'fa-palette','name'=>'Style Claude','color'=>'#8b5cf6'],
'capabilities' => ['icon'=>'fa-tools','name'=>'Capacités','color'=>'#f59e0b'],
'artifacts' => ['icon'=>'fa-cube','name'=>'Artifacts','color'=>'#ec4899'],
'thinking' => ['icon'=>'fa-lightbulb','name'=>'Réflexion','color'=>'#10b981'],
'safety' => ['icon'=>'fa-shield-alt','name'=>'Sécurité','color'=>'#ef4444'],
'context' => ['icon'=>'fa-server','name'=>'Contexte','color'=>'#6366f1'],
'ai_params' => ['icon'=>'fa-sliders-h','name'=>'Paramètres IA','color'=>'#14b8a6'],
'knowledge' => ['icon'=>'fa-book','name'=>'Knowledge Base','color'=>'#f97316'],
'prompts' => ['icon'=>'fa-edit','name'=>'Prompts','color'=>'#a855f7'],
'custom' => ['icon'=>'fa-puzzle-piece','name'=>'Personnalisé','color'=>'#64748b'],
];
$subcatNames = ['core'=>'Essentiel','claude_core'=>'🌟 Style Claude','claude_values'=>'💎 Valeurs Claude','formatting'=>'Formatage','tone'=>'Ton','adaptation'=>'Adaptation','execution'=>'Exécution','files'=>'Fichiers','analysis'=>'Documents','images'=>'Images','media'=>'Audio/Vidéo','web'=>'Web/Réseau','domain'=>'Domaines','types'=>'Types','limits'=>'Limites','display'=>'Affichage','methods'=>'Méthodes','transparency'=>'Transparence','output'=>'Sortie','filters'=>'Filtres','code'=>'Code','paths'=>'Chemins','commands'=>'Commandes','network'=>'Réseau','server'=>'Serveur','database'=>'Base de données','generation'=>'Génération','reliability'=>'Fiabilité','memory'=>'Mémoire','search'=>'Recherche','learning'=>'Apprentissage','main'=>'Principal','modifiers'=>'Modificateurs','special'=>'Spécial','fewshot'=>'Few-shot','constraints'=>'Contraintes','personality'=>'Personnalité','appearance'=>'Apparence','messages'=>'Messages'];
?>
<!DOCTYPE html>
<html data-theme="dark" lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>🧠 WEVAL MIND Brain Config Pro</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
<style>
*{margin:0;padding:0;box-sizing:border-box}
body{font-family:'Segoe UI',system-ui,sans-serif;background:#0a0a0f;color:#e2e8f0;min-height:100vh}
.container{max-width:1900px;margin:0 auto;padding:10px}
.header{display:flex;justify-content:space-between;align-items:center;padding:10px 15px;background:linear-gradient(135deg,rgba(6,182,212,0.1),rgba(139,92,246,0.1));border:1px solid rgba(255,255,255,0.1);border-radius:10px;margin-bottom:10px}
.header h1{font-size:18px;display:flex;align-items:center;gap:8px}
.header h1 i{color:#06b6d4}
.header-actions{display:flex;gap:6px;flex-wrap:wrap}
.nav-btn{color:#94a3b8;text-decoration:none;padding:5px 10px;background:rgba(255,255,255,0.05);border-radius:5px;font-size:11px;border:1px solid transparent;transition:all 0.2s;cursor:pointer}
.nav-btn:hover{background:rgba(6,182,212,0.2);color:#06b6d4}
.nav-btn.active{background:rgba(6,182,212,0.2);color:#06b6d4}
.toolbar{display:flex;gap:6px;padding:8px;background:rgba(255,255,255,0.02);border-radius:8px;margin-bottom:10px;flex-wrap:wrap;align-items:center}
.tool-btn{padding:5px 10px;background:rgba(255,255,255,0.05);border:1px solid rgba(255,255,255,0.1);border-radius:5px;color:#94a3b8;cursor:pointer;font-size:11px;display:flex;align-items:center;gap:5px;transition:all 0.2s}
.tool-btn:hover{background:rgba(6,182,212,0.2);color:#06b6d4}
.message{padding:8px 12px;border-radius:6px;margin-bottom:10px;font-size:12px}
.message.success{background:rgba(16,185,129,0.15);color:#10b981;border:1px solid rgba(16,185,129,0.3)}
.message.error{background:rgba(239,68,68,0.15);color:#ef4444}
.layout{display:grid;grid-template-columns:180px 1fr 320px;gap:10px;height:calc(100vh - 160px)}
@media(max-width:1200px){.layout{grid-template-columns:1fr;height:auto}.sidebar,.preview-panel{display:none}}
.sidebar{background:rgba(255,255,255,0.02);border-radius:8px;padding:6px;overflow-y:auto;border:1px solid rgba(255,255,255,0.05)}
.sidebar-item{padding:7px 9px;border-radius:5px;cursor:pointer;margin-bottom:2px;transition:all 0.15s;display:flex;align-items:center;gap:7px;font-size:11px;border-left:2px solid transparent}
.sidebar-item:hover{background:rgba(255,255,255,0.05)}
.sidebar-item.active{background:rgba(6,182,212,0.15);border-left-color:#06b6d4}
.sidebar-item i{width:14px;text-align:center;font-size:10px}
.sidebar-item .badge{margin-left:auto;background:rgba(255,255,255,0.1);padding:1px 5px;border-radius:6px;font-size:9px}
.main{overflow-y:auto;padding-right:6px}
.main::-webkit-scrollbar{width:5px}
.main::-webkit-scrollbar-thumb{background:rgba(255,255,255,0.1);border-radius:3px}
.card{background:rgba(255,255,255,0.03);border-radius:8px;padding:12px;margin-bottom:10px;border:1px solid rgba(255,255,255,0.06)}
.card.hidden{display:none}
.card-header{display:flex;align-items:center;gap:8px;margin-bottom:10px;padding-bottom:8px;border-bottom:1px solid rgba(255,255,255,0.08)}
.card-header h2{font-size:14px;font-weight:600;flex:1}
.subcat{margin-bottom:12px}
.subcat-title{font-size:10px;color:#64748b;text-transform:uppercase;letter-spacing:0.5px;margin-bottom:6px;display:flex;align-items:center;gap:5px}
.subcat-title.claude{color:#8b5cf6;font-weight:600}
.field{margin-bottom:8px}
.field label{display:block;font-size:10px;color:#94a3b8;margin-bottom:3px}
.field-input{width:100%;padding:7px 9px;background:rgba(0,0,0,0.3);border:1px solid rgba(255,255,255,0.1);border-radius:5px;color:#fff;font-size:11px;transition:all 0.2s}
.field-input:focus{outline:none;border-color:#06b6d4}
textarea.field-input{min-height:60px;resize:vertical;font-family:monospace;font-size:10px}
input[type="range"]{width:100%;margin:4px 0;accent-color:#06b6d4}
.range-display{display:flex;justify-content:space-between;font-size:9px;color:#64748b}
.check-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:4px}
.check{display:flex;align-items:center;gap:6px;padding:6px 8px;background:rgba(0,0,0,0.2);border-radius:5px;cursor:pointer;transition:all 0.15s;border:1px solid transparent;font-size:10px}
.check:hover{background:rgba(0,0,0,0.3)}
.check.on{background:rgba(6,182,212,0.1);border-color:rgba(6,182,212,0.3)}
.check.claude{border-left:2px solid #8b5cf6}
.check.claude.on{background:rgba(139,92,246,0.15);border-color:rgba(139,92,246,0.4)}
.check.claude label{color:#c4b5fd}
.check input{width:12px;height:12px;cursor:pointer;accent-color:#06b6d4}
.check.claude input{accent-color:#8b5cf6}
.check label{cursor:pointer;flex:1;line-height:1.2}
.check.advanced{opacity:0.5}
.check.advanced.on{opacity:1}
.preview-panel{background:rgba(255,255,255,0.02);border-radius:8px;padding:10px;overflow:hidden;display:flex;flex-direction:column;border:1px solid rgba(255,255,255,0.05)}
.preview-panel h3{font-size:12px;color:#06b6d4;margin-bottom:6px}
.preview{flex:1;background:#0d1117;border-radius:5px;padding:8px;font-family:monospace;font-size:9px;white-space:pre-wrap;overflow-y:auto;border:1px solid #21262d;line-height:1.4}
.preview-stats{margin-top:6px;font-size:9px;color:#64748b;display:flex;justify-content:space-between}
.actions-bar{display:flex;gap:6px;padding:10px;background:rgba(255,255,255,0.02);border-radius:8px;justify-content:center}
.btn{padding:8px 16px;border:none;border-radius:5px;cursor:pointer;font-weight:600;font-size:11px;transition:all 0.2s;display:flex;align-items:center;gap:5px}
.btn-primary{background:linear-gradient(135deg,#06b6d4,#0891b2);color:#fff}
.btn-primary:hover{transform:translateY(-1px);box-shadow:0 3px 10px rgba(6,182,212,0.4)}
.btn-secondary{background:rgba(255,255,255,0.08);color:#e2e8f0}
.modal{display:none;position:fixed;inset:0;background:rgba(0,0,0,0.8);z-index:1000;align-items:center;justify-content:center}
.modal.open{display:flex}
.modal-content{background:#1a1a2e;border-radius:10px;padding:16px;width:90%;max-width:450px;border:1px solid rgba(255,255,255,0.1)}
.modal-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:12px}
.modal-header h3{font-size:14px}
.modal-close{background:none;border:none;color:#64748b;cursor:pointer;font-size:16px}
.legend{display:flex;gap:12px;font-size:10px;color:#64748b;padding:6px 10px;background:rgba(0,0,0,0.2);border-radius:5px;margin-bottom:8px}
.legend-item{display:flex;align-items:center;gap:4px}
.legend-dot{width:8px;height:8px;border-radius:2px}
.legend-dot.claude{background:#8b5cf6}
.legend-dot.normal{background:#06b6d4}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1><i class="fas fa-brain"></i> WEVAL MIND Brain Config <span style="font-size:10px;color:#64748b">Pro v2</span></h1>
<div class="header-actions">
<a href="/hamid-fullscreen.php" class="nav-btn"><i class="fas fa-comments"></i> Chat</a>
<a href="/hamid-monitor.php" class="nav-btn"><i class="fas fa-heartbeat"></i> Monitor</a>
<a href="/hamid-code/" class="nav-btn"><i class="fas fa-code"></i> Code</a>
<a href="?advanced=<?=$showAdvanced?'0':'1'?>" class="nav-btn <?=$showAdvanced?'active':''?>"><i class="fas fa-flask"></i> Avancé</a>
</div>
</div>
<div class="toolbar">
<button type="button" class="tool-btn" onclick="openModal('addModal')"><i class="fas fa-plus"></i> Ajouter</button>
<a href="?export=1" class="tool-btn"><i class="fas fa-download"></i> Export</a>
<span style="font-size:10px;color:#64748b;margin-left:auto"><i class="fas fa-database"></i> <?=array_sum(array_map(fn($c)=>array_sum(array_map('count',$c)),$configs))?> configs</span>
</div>
<div class="legend">
<div class="legend-item"><div class="legend-dot claude"></div> Feature Claude (cochée par défaut)</div>
<div class="legend-item"><div class="legend-dot normal"></div> Option standard</div>
</div>
<?php if($message):?><div class="message <?=$msgType?>"><?=$message?></div><?php endif;?>
<form method="POST">
<div class="layout">
<div class="sidebar">
<?php foreach($categories as $catKey => $cat):
$count = isset($configs[$catKey]) ? array_sum(array_map('count', $configs[$catKey])) : 0;
if ($count === 0 && $catKey !== 'custom') continue;
?>
<div class="sidebar-item <?=$catKey==='identity'?'active':''?>" onclick="showCategory('<?=$catKey?>')" style="--cat-color:<?=$cat['color']?>">
<i class="fas <?=$cat['icon']?>" style="color:<?=$cat['color']?>"></i>
<?=$cat['name']?>
<span class="badge"><?=$count?></span>
</div>
<?php endforeach; ?>
</div>
<div class="main">
<?php foreach($categories as $catKey => $cat): if (!isset($configs[$catKey])) continue; ?>
<div class="card <?=$catKey!=='identity'?'hidden':''?>" id="cat-<?=$catKey?>">
<div class="card-header" style="border-left:2px solid <?=$cat['color']?>">
<i class="fas <?=$cat['icon']?>" style="color:<?=$cat['color']?>"></i>
<h2><?=$cat['name']?></h2>
</div>
<?php foreach($configs[$catKey] as $subcat => $items):
$hasCheckboxes = count(array_filter($items, fn($i) => $i['field_type'] === 'checkbox')) > 0;
$isClaudeSubcat = strpos($subcat, 'claude') !== false;
?>
<?php if(count($configs[$catKey]) > 1): ?>
<div class="subcat-title <?=$isClaudeSubcat?'claude':''?>"><?=$subcatNames[$subcat] ?? ucfirst($subcat)?></div>
<?php endif; ?>
<?php if($hasCheckboxes): ?><div class="check-grid"><?php endif; ?>
<?php foreach($items as $c):
if ($c['is_advanced'] && !$showAdvanced) continue;
$isClaude = $c['is_claude_feature'] ?? 0;
?>
<?php if($c['field_type'] === 'checkbox'): ?>
<div class="check <?=$c['config_value']=='1'?'on':''?> <?=$isClaude?'claude':''?> <?=$c['is_advanced']?'advanced':''?>">
<input type="hidden" name="cfg[<?=$c['config_key']?>]" value="0">
<input type="checkbox" name="cfg[<?=$c['config_key']?>]" value="1" <?=$c['config_value']=='1'?'checked':''?> id="<?=$c['config_key']?>" onchange="this.parentElement.classList.toggle('on',this.checked)">
<label for="<?=$c['config_key']?>"><?=$c['description']?></label>
</div>
<?php elseif($c['field_type'] === 'select'): ?>
<div class="field">
<label><?=$c['description']?></label>
<select name="cfg[<?=$c['config_key']?>]" class="field-input">
<?php foreach(explode(',', $c['options']) as $opt): ?>
<option value="<?=$opt?>" <?=$c['config_value']===$opt?'selected':''?>><?=ucfirst($opt)?></option>
<?php endforeach; ?>
</select>
</div>
<?php elseif($c['field_type'] === 'textarea'): ?>
<div class="field">
<label><?=$c['description']?></label>
<textarea name="cfg[<?=$c['config_key']?>]" class="field-input"><?=htmlspecialchars($c['config_value'])?></textarea>
</div>
<?php elseif($c['field_type'] === 'range'):
$opts = explode(',', $c['options']); $min=$opts[0]??0; $max=$opts[1]??1; $step=$opts[2]??0.1;
?>
<div class="field">
<label><?=$c['description']?></label>
<input type="range" name="cfg[<?=$c['config_key']?>]" value="<?=$c['config_value']?>" min="<?=$min?>" max="<?=$max?>" step="<?=$step?>" oninput="this.nextElementSibling.querySelector('span').textContent=this.value">
<div class="range-display"><span><?=$min?></span><span><?=$c['config_value']?></span><span><?=$max?></span></div>
</div>
<?php elseif($c['field_type'] === 'color'): ?>
<div class="field">
<label><?=$c['description']?></label>
<input type="color" name="cfg[<?=$c['config_key']?>]" value="<?=htmlspecialchars($c['config_value'])?>" class="field-input" style="height:32px;padding:2px">
</div>
<?php else: ?>
<div class="field">
<label><?=$c['description']?></label>
<input type="<?=$c['field_type']?>" name="cfg[<?=$c['config_key']?>]" value="<?=htmlspecialchars($c['config_value'])?>" class="field-input">
</div>
<?php endif; ?>
<?php endforeach; ?>
<?php if($hasCheckboxes): ?></div><?php endif; ?>
<?php endforeach; ?>
</div>
<?php endforeach; ?>
</div>
<div class="preview-panel">
<h3><i class="fas fa-eye"></i> System Prompt</h3>
<div class="preview"><?=htmlspecialchars($prompt)?></div>
<div class="preview-stats">
<span><?=strlen($prompt)?> chars</span>
<span>~<?=round(strlen($prompt)/4)?> tokens</span>
</div>
</div>
</div>
<div class="actions-bar">
<button type="submit" name="save" value="1" class="btn btn-primary"><i class="fas fa-save"></i> Sauvegarder</button>
<button type="button" class="btn btn-secondary" onclick="location.reload()"><i class="fas fa-undo"></i> Annuler</button>
</div>
</form>
</div>
<div class="modal" id="addModal">
<div class="modal-content">
<div class="modal-header">
<h3><i class="fas fa-plus"></i> Ajouter configuration</h3>
<button class="modal-close" onclick="closeModal('addModal')">&times;</button>
</div>
<form method="POST">
<div class="field"><label>Clé</label><input type="text" name="new_key" class="field-input" required pattern="[a-z0-9_]+"></div>
<div class="field"><label>Valeur</label><input type="text" name="new_value" class="field-input"></div>
<div class="field"><label>Description</label><input type="text" name="new_description" class="field-input"></div>
<div class="field"><label>Catégorie</label>
<select name="new_category" class="field-input">
<?php foreach($categories as $k=>$c):?><option value="<?=$k?>"><?=$c['name']?></option><?php endforeach;?>
</select>
</div>
<div class="field"><label>Type</label>
<select name="new_type" class="field-input">
<option value="text">Texte</option><option value="textarea">Textarea</option><option value="number">Nombre</option>
<option value="checkbox">Checkbox</option><option value="select">Select</option><option value="color">Couleur</option>
</select>
</div>
<div class="field"><label>Options (select: opt1,opt2)</label><input type="text" name="new_options" class="field-input"></div>
<div class="check" style="margin:10px 0"><input type="checkbox" name="new_claude" value="1" id="newclaude"><label for="newclaude">Feature Claude (style distinctif)</label></div>
<div style="display:flex;gap:8px;justify-content:flex-end;margin-top:12px">
<button type="button" class="btn btn-secondary" onclick="closeModal('addModal')">Annuler</button>
<button type="submit" name="add_config" value="1" class="btn btn-primary"><i class="fas fa-plus"></i> Ajouter</button>
</div>
</form>
</div>
</div>
<script>
function showCategory(cat){document.querySelectorAll('.card').forEach(c=>c.classList.add('hidden'));document.querySelectorAll('.sidebar-item').forEach(s=>s.classList.remove('active'));document.getElementById('cat-'+cat)?.classList.remove('hidden');document.querySelector(`[onclick="showCategory('${cat}')"]`)?.classList.add('active');}
function openModal(id){document.getElementById(id).classList.add('open');}
function closeModal(id){document.getElementById(id).classList.remove('open');}
</script>
</body>
</html>