fix(coding-agent): show models.json auth in login selector
This commit is contained in:
@@ -35,7 +35,7 @@ export type AuthStorageData = Record<string, AuthCredential>;
|
||||
|
||||
export type AuthStatus = {
|
||||
configured: boolean;
|
||||
source?: "stored" | "runtime" | "environment" | "fallback";
|
||||
source?: "stored" | "runtime" | "environment" | "fallback" | "models_json_key" | "models_json_command";
|
||||
label?: string;
|
||||
};
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import { type Static, Type } from "typebox";
|
||||
import { Compile } from "typebox/compile";
|
||||
import type { TLocalizedValidationError } from "typebox/error";
|
||||
import { getAgentDir } from "../config.js";
|
||||
import type { AuthStorage } from "./auth-storage.js";
|
||||
import type { AuthStatus, AuthStorage } from "./auth-storage.js";
|
||||
import {
|
||||
clearConfigValueCache,
|
||||
resolveConfigValueOrThrow,
|
||||
@@ -701,6 +701,32 @@ export class ModelRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return auth status for a provider, including request auth configured in models.json.
|
||||
* This intentionally does not execute command-backed config values.
|
||||
*/
|
||||
getProviderAuthStatus(provider: string): AuthStatus {
|
||||
const authStatus = this.authStorage.getAuthStatus(provider);
|
||||
if (authStatus.source) {
|
||||
return authStatus;
|
||||
}
|
||||
|
||||
const providerApiKey = this.providerRequestConfigs.get(provider)?.apiKey;
|
||||
if (!providerApiKey) {
|
||||
return authStatus;
|
||||
}
|
||||
|
||||
if (providerApiKey.startsWith("!")) {
|
||||
return { configured: true, source: "models_json_command" };
|
||||
}
|
||||
|
||||
if (process.env[providerApiKey]) {
|
||||
return { configured: true, source: "environment", label: providerApiKey };
|
||||
}
|
||||
|
||||
return { configured: true, source: "models_json_key" };
|
||||
}
|
||||
|
||||
/**
|
||||
* Get API key for a provider.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user