/** Main entry point — wires all modules together. */ import { initAuth, authToken, startLogin } from './auth.js'; import { initTrace, addTrace, clearTrace } from './trace.js'; import { initChat, clearChat } from './chat.js'; import { clearDashboard } from './dashboard.js'; import { initGraph } from './graph.js'; import { connect } from './ws.js'; // Init on load window.addEventListener('load', async () => { initTrace(); initChat(); await initGraph(); await initAuth(() => connect()); }); // Clear session button window.clearSession = async () => { try { const headers = { 'Content-Type': 'application/json' }; if (authToken) headers['Authorization'] = 'Bearer ' + authToken; await fetch('/api/clear', { method: 'POST', headers }); clearChat(); clearTrace(); clearDashboard(); addTrace('runtime', 'cleared', 'session reset'); } catch (e) { addTrace('runtime', 'error', 'clear failed: ' + e); } }; // Login button window.startLogin = startLogin;