fix: support both Codex and Nous auth structures in OAuth provider detection (#141)

The isOAuthAuthorized check only looked for Codex's nested
`providers.{key}.tokens.access_token` structure, missing Nous's flat
`providers.nous.access_token`. Now checks both paths so all OAuth
providers are correctly detected and displayed in the provider list.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
ekko
2026-04-23 08:48:06 +08:00
committed by GitHub
parent df797d09b2
commit 32dc084b66
2 changed files with 9 additions and 2 deletions
@@ -46,7 +46,14 @@ export async function getAvailable(ctx: any) {
const authPath = getActiveAuthPath()
if (!existsSync(authPath)) return false
const auth = JSON.parse(readFileSync(authPath, 'utf-8'))
return !!auth.providers?.[providerKey]?.tokens?.access_token
const provider = auth.providers?.[providerKey]
if (!provider) return false
// Codex: providers.openai-codex.tokens.access_token
// Nous: providers.nous.access_token
return !!(
provider.tokens?.access_token ||
provider.access_token
)
} catch { return false }
}