fix(coding-agent,ai): show env auth source in /login

This commit is contained in:
Armin Ronacher
2026-04-23 21:01:55 +02:00
parent 05e2e9d170
commit e97051313d
10 changed files with 352 additions and 48 deletions

View File

@@ -8,6 +8,7 @@
import {
getEnvApiKey,
getEnvApiKeyInfo,
type OAuthCredentials,
type OAuthLoginCallbacks,
type OAuthProviderId,
@@ -32,6 +33,12 @@ export type AuthCredential = ApiKeyCredential | OAuthCredential;
export type AuthStorageData = Record<string, AuthCredential>;
export type AuthStatus = {
configured: boolean;
source?: "stored" | "runtime" | "environment" | "fallback";
label?: string;
};
type LockResult<T> = {
result: T;
next?: string;
@@ -329,6 +336,30 @@ export class AuthStorage {
return false;
}
/**
* Return auth status without exposing credential values or refreshing tokens.
*/
getAuthStatus(provider: string): AuthStatus {
if (this.data[provider]) {
return { configured: true, source: "stored" };
}
if (this.runtimeOverrides.has(provider)) {
return { configured: false, source: "runtime", label: "--api-key" };
}
const envKey = getEnvApiKeyInfo(provider);
if (envKey) {
return { configured: false, source: "environment", label: envKey.label };
}
if (this.fallbackResolver?.(provider)) {
return { configured: false, source: "fallback", label: "custom provider config" };
}
return { configured: false };
}
/**
* Get all credentials (for passing to getOAuthApiKey).
*/