(ctx context.Context, auth *coreauth.Auth)
| 314 | } |
| 315 | |
| 316 | func (h *Host) ModelsForAuth(ctx context.Context, auth *coreauth.Auth) AuthModelResult { |
| 317 | if h == nil || auth == nil { |
| 318 | return AuthModelResult{} |
| 319 | } |
| 320 | providerKey := normalizeProviderID(auth.Provider) |
| 321 | if providerKey == "" { |
| 322 | return AuthModelResult{} |
| 323 | } |
| 324 | for _, record := range h.activeRecords() { |
| 325 | modelProvider := record.plugin.Capabilities.ModelProvider |
| 326 | if modelProvider == nil || h.isPluginFused(record.id) { |
| 327 | continue |
| 328 | } |
| 329 | if !executorScopeAllowsOAuthModels(record.plugin.Capabilities) { |
| 330 | continue |
| 331 | } |
| 332 | authProvider := record.plugin.Capabilities.AuthProvider |
| 333 | if authProvider != nil { |
| 334 | identifier, okIdentifier := h.callAuthProviderIdentifier(record.id, authProvider) |
| 335 | if !okIdentifier || normalizeProviderID(identifier) != providerKey { |
| 336 | continue |
| 337 | } |
| 338 | } else { |
| 339 | recordProvider := normalizeProviderID(h.modelProvider(record.id)) |
| 340 | if recordProvider == "" { |
| 341 | executor := record.plugin.Capabilities.Executor |
| 342 | if executor != nil { |
| 343 | candidate, okCandidate := h.executorProvider(record, executor) |
| 344 | if okCandidate { |
| 345 | recordProvider = candidate |
| 346 | } |
| 347 | } |
| 348 | } |
| 349 | if recordProvider != providerKey { |
| 350 | continue |
| 351 | } |
| 352 | } |
| 353 | resp, errModels := h.callModelsForAuth(ctx, record, modelProvider, auth) |
| 354 | if errModels != nil { |
| 355 | log.Warnf("pluginhost: models for auth %s failed: %v", auth.ID, errModels) |
| 356 | return AuthModelResult{Handled: true, Err: errModels} |
| 357 | } |
| 358 | respProvider := normalizeProviderID(resp.Provider) |
| 359 | if respProvider != "" && respProvider != providerKey { |
| 360 | continue |
| 361 | } |
| 362 | if respProvider == "" { |
| 363 | respProvider = providerKey |
| 364 | } |
| 365 | models := make([]*registry.ModelInfo, 0, len(resp.Models)) |
| 366 | for _, item := range resp.Models { |
| 367 | model := pluginModelInfoToRegistryModelInfo(item) |
| 368 | if model != nil { |
| 369 | model.ID = strings.TrimSpace(model.ID) |
| 370 | } |
| 371 | if model != nil && model.ID != "" { |
| 372 | models = append(models, model) |
| 373 | } |
nothing calls this directly
no test coverage detected