// API Constants export const API_STATE = '/api/state'; export const API_STREAM = '/api/stream'; export const API_DISMISS = '/api/dismiss/'; export const API_RESPOND = '/api/respond/'; export const API_CONVERSATION = '/api/conversation/'; export const POLL_MS = 3000; export const API_TIMEOUT_MS = 10000; // Fetch with timeout to prevent hanging requests export async function fetchWithTimeout(url, options = {}, timeoutMs = API_TIMEOUT_MS) { const controller = new AbortController(); const timeoutId = setTimeout(() => controller.abort(), timeoutMs); try { const response = await fetch(url, { ...options, signal: controller.signal }); return response; } finally { clearTimeout(timeoutId); } }