@php $currentStatus = $currentStatus ?? 'all'; $statusPill = [ 'active' => ['bg' => 'bg-wa-mint', 'text' => 'text-wa-deep', 'dot' => 'bg-wa-green', 'label' => 'Active'], 'paused' => ['bg' => 'bg-paper-50', 'text' => 'text-ink-500', 'dot' => 'bg-paper-200', 'label' => 'Paused'], ]; // Bespoke colour themes for the providers that have brand colours; every // other supported provider (deepseek, mistral, xai, openrouter, …) uses // the neutral theme but still shows its OWN name. Previously the map only // knew openai/anthropic/gemini and defaulted everything else to the // OpenAI pill — so a DeepSeek/Mistral agent was mislabelled "OpenAI". $providerThemes = [ 'openai' => ['bg' => 'bg-wa-mint', 'text' => 'text-wa-deep', 'dot' => 'bg-wa-green'], 'anthropic' => ['bg' => 'bg-[#F3E9FF]', 'text' => 'text-[#5B3D8A]', 'dot' => 'bg-[#7A52B2]'], 'gemini' => ['bg' => 'bg-[#D9E5F2]', 'text' => 'text-[#13478A]', 'dot' => 'bg-[#3D6FB5]'], 'deepseek' => ['bg' => 'bg-[#E7EEFF]', 'text' => 'text-[#2743B0]', 'dot' => 'bg-[#4C6EF5]'], 'mistral' => ['bg' => 'bg-[#FCE9DE]', 'text' => 'text-[#A1431F]', 'dot' => 'bg-[#E87A5D]'], 'xai' => ['bg' => 'bg-[#ECECEC]', 'text' => 'text-[#222]', 'dot' => 'bg-[#444]'], ]; // Display label per provider slug (validated set in AiTrainingController). $providerLabels = [ 'openai' => 'OpenAI', 'anthropic' => 'Anthropic', 'gemini' => 'Gemini', 'mistral' => 'Mistral', 'deepseek' => 'DeepSeek', 'xai' => 'xAI', 'perplexity' => 'Perplexity', 'groq' => 'Groq', 'qwen' => 'Qwen', 'moonshot' => 'Moonshot', 'zai' => 'Z.ai', 'cohere' => 'Cohere', 'nvidia' => 'NVIDIA', 'llama' => 'Llama', 'huggingface' => 'Hugging Face', 'baidu' => 'Baidu', 'ai21' => 'AI21', 'reka' => 'Reka', 'yi' => 'Yi', 'openrouter' => 'OpenRouter', ]; $providerDefaultTheme = ['bg' => 'bg-paper-100', 'text' => 'text-ink-700', 'dot' => 'bg-paper-300']; $accentPalette = [ ['bg' => 'bg-wa-mint', 'text' => 'text-wa-deep'], ['bg' => 'bg-[#D9E5F2]', 'text' => 'text-[#13478A]'], ['bg' => 'bg-[#F3E9FF]', 'text' => 'text-[#5B3D8A]'], ['bg' => 'bg-paper-100', 'text' => 'text-ink-700'], ]; @endphp
@if (session('success'))
{{ session('success') }}
@endif @if (session('status'))
{{ session('status') }}
@endif {{-- Meta Business Agent coexistence — choose who answers, never reply twice. $_mode / $_metaOn / $modes are passed from AiTrainingController::index (not inline) so they're always bound even if a host serves a stale-compiled view. --}}
@csrf

{{ __('Who answers your WhatsApp?') }}

{{ __('If you turn on Meta’s own Business Agent, our AI + keyword auto-replies stand down for this workspace — so your customer never gets two answers to the same message.') }}

{{-- $modes is passed from AiTrainingController::index (not defined inline) so it's always bound; the ?? [] is a final safety net. --}}
@foreach (($modes ?? []) as $key => [$label, $desc]) @endforeach
{{ __('Meta’s agent needs a WhatsApp Business (Cloud API) number — Unofficial-API numbers always use our AI.') }}
{{ __('Workspace') }}

AI {{ __('Training') }}

{{ __("Build smart agents that speak in your brand's voice — train them on URLs, text, Q&A pairs, and plain-text files.") }}

{{ $stats['active'] }} {{ __('active') }} New smart agent
{{ __('Total agents') }}
{{ $stats['all'] }}{{ $stats['active'] }} {{ __('active') }}
{{ __('Knowledge entries') }}
{{ number_format($stats['sources']) }}{{ $stats['ready'] }} {{ __('indexed') }}
{{ __('Avg / agent') }}
{{ $stats['all'] > 0 ? number_format($stats['sources'] / $stats['all'], 1) : '0' }}{{ __('entries') }}
{{ __('Health') }}{{ $stats['all'] > 0 ? round(($stats['active'] / max($stats['all'], 1)) * 100) : 0 }}%
{{ $stats['all'] > 0 && $stats['active'] === $stats['all'] ? 'healthy' : ($stats['all'] === 0 ? 'empty' : 'attention') }}
{{ __('Agent') }}
{{ __('Provider') }}
{{ __('Knowledge') }}
{{ __('Tone') }}
{{ __('Updated') }}
{{ __('Actions') }}
@forelse ($assistants as $a) @php $accent = $accentPalette[$a->id % 4]; $status = $statusPill[$a->status] ?? $statusPill['active']; $provKey = (string) $a->ai_provider; $provider = ($providerThemes[$provKey] ?? $providerDefaultTheme) + ['label' => $providerLabels[$provKey] ?? ($provKey !== '' ? ucfirst($provKey) : 'OpenAI')]; @endphp
{{ $a->name }} {{ $status['label'] }}
/{{ $a->slug }} · {{ $a->ai_model }}
{{ $provider['label'] }}
{{ ($a->training_sources_count ?? 0) > 0 ? number_format($a->training_sources_count) . ' entries' : '—' }}
{{ $a->tone ?? 'helpful' }}
{{ $a->updated_at->diffForHumans(short: true) }}
{{ $a->updated_at->format('M d, H:i') }}
@csrf
@empty
{{ __('No smart agents yet') }}

{{ __('Build your first agent — the 5-step builder walks you through identity, persona, brain, safety, and the knowledge it should know.') }}

Build smart agent
@endforelse
{{ __('Showing') }} {{ $assistants->count() }} of {{ method_exists($assistants, 'total') ? number_format($assistants->total()) : number_format($stats['all']) }}
Workspace · {{ $stats['all'] }} {{ __('agents') }}
@if (method_exists($assistants, 'links')) {{ $assistants->links() }} @endif