(
cfg: Config,
hint: { provider: string; modelId: string },
)
| 224 | } |
| 225 | |
| 226 | export function resolveActiveModel( |
| 227 | cfg: Config, |
| 228 | hint: { provider: string; modelId: string }, |
| 229 | ): ActiveModelResolution { |
| 230 | const activeId = cfg.activeProvider; |
| 231 | const entry = resolveEntryFor(cfg, activeId); |
| 232 | if (entry === null) { |
| 233 | throw new CodesignError( |
| 234 | `Active provider "${activeId}" has no provider entry on disk.`, |
| 235 | ERROR_CODES.PROVIDER_NOT_SUPPORTED, |
| 236 | ); |
| 237 | } |
| 238 | const allowKeyless = isKeylessProviderAllowed(activeId, entry); |
| 239 | if (cfg.secrets[activeId] === undefined && !allowKeyless) { |
| 240 | throw new CodesignError( |
| 241 | `No API key stored for active provider "${activeId}". Re-run onboarding to add one.`, |
| 242 | ERROR_CODES.PROVIDER_KEY_MISSING, |
| 243 | ); |
| 244 | } |
| 245 | const overridden = activeId !== hint.provider; |
| 246 | const modelId = overridden ? cfg.activeModel : hint.modelId; |
| 247 | return { |
| 248 | model: { provider: activeId, modelId }, |
| 249 | baseUrl: entry.baseUrl, |
| 250 | wire: entry.wire, |
| 251 | httpHeaders: entry.httpHeaders, |
| 252 | queryParams: entry.queryParams, |
| 253 | reasoningLevel: entry.reasoningLevel, |
| 254 | allowKeyless, |
| 255 | overridden, |
| 256 | }; |
| 257 | } |
no test coverage detected