* Fetch with timeout helper. We don't want a wizard step to hang for 30s on a * stuck socket, so every probe gets a hard budget.
(url: string, timeoutMs = PROBE_TIMEOUT_MS)
| 59 | * stuck socket, so every probe gets a hard budget. |
| 60 | */ |
| 61 | async function fetchWithTimeout(url: string, timeoutMs = PROBE_TIMEOUT_MS): Promise<Response | null> { |
| 62 | const controller = new AbortController(); |
| 63 | const timer = setTimeout(() => controller.abort(), timeoutMs); |
| 64 | try { |
| 65 | const r = await fetch(url, { signal: controller.signal }); |
| 66 | return r; |
| 67 | } catch (e: any) { |
| 68 | logger.debug(`probe failed: ${url}`, { err: e?.message ?? String(e) }); |
| 69 | return null; |
| 70 | } finally { |
| 71 | clearTimeout(timer); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | /** Probe Ollama daemon for installed models. */ |
| 76 | export async function detectOllamaModels(baseUrl = 'http://localhost:11434'): Promise<DetectedModel[]> { |
no test coverage detected