fix(cli): honor agent for model auth logout (#85326)

This commit is contained in:
Peter Steinberger
2026-05-22 13:46:07 +01:00
committed by GitHub
parent 4a9138556e
commit fc47c1f55e
3 changed files with 43 additions and 4 deletions

View File

@@ -920,9 +920,10 @@ async function runModelAuthStatus() {
return raw ? (JSON.parse(raw) as Record<string, unknown>) : {};
}
async function runModelAuthLogout(provider: string) {
async function runModelAuthLogout(provider: string, agent?: string) {
const cfg = getRuntimeConfig();
const agentDir = resolveAgentDir(cfg, resolveDefaultAgentId(cfg));
const agentId = agent?.trim() || resolveDefaultAgentId(cfg);
const agentDir = resolveAgentDir(cfg, agentId);
const store = loadAuthProfileStoreForRuntime(agentDir);
const profileIds = listProfilesForProvider(store, provider);
const updated = await updateAuthProfileStoreWithLock({
@@ -1882,10 +1883,14 @@ export function registerCapabilityCli(program: Command) {
.command("logout")
.description("Remove saved auth profiles for one provider")
.requiredOption("--provider <id>", "Provider id")
.option("--agent <id>", "Agent id (default: configured default agent)")
.option("--json", "Output JSON", false)
.action(async (opts) => {
await runCommandWithRuntime(defaultRuntime, async () => {
const result = await runModelAuthLogout(String(opts.provider));
const result = await runModelAuthLogout(
String(opts.provider),
typeof opts.agent === "string" ? opts.agent : undefined,
);
emitJsonOrText(defaultRuntime, Boolean(opts.json), result, (value) =>
JSON.stringify(value, null, 2),
);