fix(coding-agent): show models.json auth in login selector

This commit is contained in:
Armin Ronacher
2026-04-24 17:27:53 +02:00
parent 3e0ee69b5e
commit 39db145495
8 changed files with 197 additions and 139 deletions

View File

@@ -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;
};

View File

@@ -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.
*/