export interface AssistantWidgetAvailabilityOptions { endpoint?: string; fetch?: typeof globalThis.fetch; } export async function isAssistantWidgetAvailable( options: AssistantWidgetAvailabilityOptions = {}, ): Promise { const fetcher = options.fetch ?? globalThis.fetch; if (typeof fetcher !== 'function') { return false; } try { const response = await fetcher(options.endpoint ?? '/api/ai-api/list', { credentials: 'include', headers: { Accept: 'application/json' }, }); if (!response.ok) { return false; } const body = await response.json() as { success?: unknown }; return body.success === true; } catch { return false; } }