refactor(commands): dedupe auth-choice model notes

This commit is contained in:
Peter Steinberger
2026-02-18 23:32:55 +00:00
parent 4e62bdf78d
commit 0048af4e2d
4 changed files with 8 additions and 45 deletions

View File

@@ -5,6 +5,7 @@ import {
normalizeApiKeyInput,
validateApiKeyInput,
} from "./auth-choice.api-key.js";
import { createAuthChoiceAgentModelNoter } from "./auth-choice.apply-helpers.js";
import type { ApplyAuthChoiceParams, ApplyAuthChoiceResult } from "./auth-choice.apply.js";
import { applyDefaultModelChoice } from "./auth-choice.default-model.js";
import { isRemoteEnvironment } from "./oauth-env.js";
@@ -24,6 +25,7 @@ import {
export async function applyAuthChoiceOpenAI(
params: ApplyAuthChoiceParams,
): Promise<ApplyAuthChoiceResult | null> {
const noteAgentModel = createAuthChoiceAgentModelNoter(params);
let authChoice = params.authChoice;
if (authChoice === "apiKey" && params.opts?.tokenProvider === "openai") {
authChoice = "openai-api-key";
@@ -32,15 +34,6 @@ export async function applyAuthChoiceOpenAI(
if (authChoice === "openai-api-key") {
let nextConfig = params.config;
let agentModelOverride: string | undefined;
const noteAgentModel = async (model: string) => {
if (!params.agentId) {
return;
}
await params.prompter.note(
`Default model set to ${model} for agent "${params.agentId}".`,
"Model configured",
);
};
const applyOpenAiDefaultModelChoice = async (): Promise<ApplyAuthChoiceResult> => {
const applied = await applyDefaultModelChoice({
@@ -106,15 +99,6 @@ export async function applyAuthChoiceOpenAI(
if (params.authChoice === "openai-codex") {
let nextConfig = params.config;
let agentModelOverride: string | undefined;
const noteAgentModel = async (model: string) => {
if (!params.agentId) {
return;
}
await params.prompter.note(
`Default model set to ${model} for agent "${params.agentId}".`,
"Model configured",
);
};
let creds;
try {