Просмотр исходного кода

fix(auth): Respect disabled/enabled providers config in auth login (#4940)

Co-authored-by: GitHub Action <[email protected]>
Co-authored-by: Aiden Cline <[email protected]>
Stephen Collings 2 месяцев назад
Родитель
Сommit
1eaf5c31d3
1 измененных файлов с 17 добавлено и 1 удалено
  1. 17 1
      packages/opencode/src/cli/cmd/auth.ts

+ 17 - 1
packages/opencode/src/cli/cmd/auth.ts

@@ -6,6 +6,7 @@ import { ModelsDev } from "../../provider/models"
 import { map, pipe, sortBy, values } from "remeda"
 import path from "path"
 import os from "os"
+import { Config } from "../../config/config"
 import { Global } from "../../global"
 import { Plugin } from "../../plugin"
 import { Instance } from "../../project/instance"
@@ -103,7 +104,22 @@ export const AuthLoginCommand = cmd({
           return
         }
         await ModelsDev.refresh().catch(() => {})
-        const providers = await ModelsDev.get()
+
+        const config = await Config.get()
+
+        const disabled = new Set(config.disabled_providers ?? [])
+        const enabled = config.enabled_providers ? new Set(config.enabled_providers) : undefined
+
+        const providers = await ModelsDev.get().then((x) => {
+          const filtered: Record<string, (typeof x)[string]> = {}
+          for (const [key, value] of Object.entries(x)) {
+            if ((enabled ? enabled.has(key) : true) && !disabled.has(key)) {
+              filtered[key] = value
+            }
+          }
+          return filtered
+        })
+
         const priority: Record<string, number> = {
           opencode: 0,
           anthropic: 1,