import React, { useEffect, useState } from 'react'; import { Cpu, Eye, RefreshCw, Zap } from 'lucide-react'; /** * CPU / ZeroGPU deployment toggle (spec.md §4.5). Controls whether the engine * escalates to the OmniParser station (GPU path) for canvas/Figma surfaces. * CPU tier stays fully functional: DOM serializer + optical CVD/blur. */ interface Capabilities { perception_mode: string; visual_perception_enabled: boolean; perception_tier: string; omniparser_configured: boolean; } const PerceptionToggle: React.FC = () => { const [caps, setCaps] = useState(null); const [busy, setBusy] = useState(false); const [note, setNote] = useState(''); const load = () => fetch('/api/account/capabilities') .then((response) => (response.ok ? response.json() : null)) .then((body) => body?.data && setCaps(body.data)) .catch(() => undefined); useEffect(() => { load(); }, []); const setMode = async (mode: 'cpu' | 'zerogpu' | 'auto') => { setBusy(true); setNote(''); try { const response = await fetch('/api/account/capabilities/perception', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ mode }), }); if (response.status === 401) { setNote('Sign in with Hugging Face to change the deployment tier.'); } else if (response.ok) { await load(); } else { setNote(`Failed (${response.status})`); } } catch { setNote('API unreachable.'); } finally { setBusy(false); } }; const tier = caps?.perception_tier; return (

Perception tier — CPU / ZeroGPU deployment

CPU tier runs the DOM serializer with optical color-blindness and acuity preprocessing — fully functional, no GPU. ZeroGPU tier additionally escalates to the OmniParser station for canvas and Figma-prototype surfaces the DOM can't describe.

{([ { id: 'cpu', label: 'CPU only', icon: Cpu, desc: 'DOM + optical filter' }, { id: 'zerogpu', label: 'ZeroGPU', icon: Zap, desc: 'OmniParser visual escalation' }, { id: 'auto', label: 'Auto', icon: Eye, desc: 'ZeroGPU if parser URL set' }, ] as const).map((option) => { const active = caps?.perception_mode === option.id; return ( ); })}
Active tier:{' '} {busy ? : tier || '…'} {caps && !caps.omniparser_configured && caps.perception_tier === 'zerogpu' && ( ⚠ OMNIPARSER_BASE_URL not set )}
{note &&

{note}

}
); }; export default PerceptionToggle;