( connection: ConnectionEffectConnection, secret: string, testModel: string, fetchFn: ConnectionEffectFetch | undefined, t0: number, timeoutMs = CONNECTION_TEST_TIMEOUT_MS, )
| 175 | } |
| 176 | |
| 177 | async function testConnectionModel( |
| 178 | connection: ConnectionEffectConnection, |
| 179 | secret: string, |
| 180 | testModel: string, |
| 181 | fetchFn: ConnectionEffectFetch | undefined, |
| 182 | t0: number, |
| 183 | timeoutMs = CONNECTION_TEST_TIMEOUT_MS, |
| 184 | ): Promise<ConnectionTestResult> { |
| 185 | const { adapter, baseUrl, wire } = resolveModelRuntime(connection, testModel); |
| 186 | |
| 187 | switch (adapter.kind) { |
| 188 | case 'anthropic': |
| 189 | case 'claude-subscription': |
| 190 | return await probeAnthropic(connection, baseUrl, secret, testModel, t0, fetchFn); |
| 191 | case 'openai': |
| 192 | return wire === 'openai-responses' |
| 193 | ? await probeOpenAIResponses(baseUrl, secret, testModel, t0, fetchFn) |
| 194 | : await probeOpenAI(connection, baseUrl, secret, testModel, t0, fetchFn, timeoutMs); |
| 195 | case 'openai-codex': |
| 196 | return await probeOpenAI(connection, baseUrl, secret, testModel, t0, fetchFn, timeoutMs); |
| 197 | case 'openai-compatible': |
| 198 | return wire === 'openai-responses' |
| 199 | ? await probeOpenAIResponses(baseUrl, secret, testModel, t0, fetchFn) |
| 200 | : await probeOpenAI(connection, baseUrl, secret, testModel, t0, fetchFn, timeoutMs); |
| 201 | case 'github-copilot': |
| 202 | return await probeGitHubCopilot(baseUrl, secret, testModel, t0, fetchFn); |
| 203 | case 'google': |
| 204 | return await probeGoogle( |
| 205 | baseUrl, |
| 206 | secret, |
| 207 | testModel, |
| 208 | t0, |
| 209 | adapter.normalizeBaseUrl !== false, |
| 210 | fetchFn, |
| 211 | ); |
| 212 | case 'cohere': |
| 213 | return await probeCohere(baseUrl, secret, testModel, t0, fetchFn); |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | async function probeGitHubCopilot( |
| 218 | baseUrl: string, |
no test coverage detected