diff --git a/src/commands/auth-choice.apply.api-providers.ts b/src/commands/auth-choice.apply.api-providers.ts index 74fdc39613..dd574b988f 100644 --- a/src/commands/auth-choice.apply.api-providers.ts +++ b/src/commands/auth-choice.apply.api-providers.ts @@ -5,6 +5,7 @@ import { normalizeApiKeyInput, validateApiKeyInput, } from "./auth-choice.api-key.js"; +import { createAuthChoiceAgentModelNoter } from "./auth-choice.apply-helpers.js"; import { applyAuthChoiceHuggingface } from "./auth-choice.apply.huggingface.js"; import type { ApplyAuthChoiceParams, ApplyAuthChoiceResult } from "./auth-choice.apply.js"; import { applyAuthChoiceOpenRouter } from "./auth-choice.apply.openrouter.js"; @@ -74,15 +75,7 @@ export async function applyAuthChoiceApiProviders( ): Promise { 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 noteAgentModel = createAuthChoiceAgentModelNoter(params); let authChoice = params.authChoice; if ( diff --git a/src/commands/auth-choice.apply.minimax.ts b/src/commands/auth-choice.apply.minimax.ts index 044ba12054..5afd52b21c 100644 --- a/src/commands/auth-choice.apply.minimax.ts +++ b/src/commands/auth-choice.apply.minimax.ts @@ -4,6 +4,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 { applyAuthChoicePluginProvider } from "./auth-choice.apply.plugin-provider.js"; import { applyDefaultModelChoice } from "./auth-choice.default-model.js"; @@ -47,15 +48,7 @@ export async function applyAuthChoiceMiniMax( await setMinimaxApiKey(normalizeApiKeyInput(String(key)), params.agentDir, opts.profileId); } }; - 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 noteAgentModel = createAuthChoiceAgentModelNoter(params); if (params.authChoice === "minimax-portal") { // Let user choose between Global/CN endpoints const endpoint = await params.prompter.select({ diff --git a/src/commands/auth-choice.apply.openai.ts b/src/commands/auth-choice.apply.openai.ts index db00f5d25a..a7e0fa976e 100644 --- a/src/commands/auth-choice.apply.openai.ts +++ b/src/commands/auth-choice.apply.openai.ts @@ -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 { + 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 => { 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 { diff --git a/src/commands/auth-choice.apply.openrouter.ts b/src/commands/auth-choice.apply.openrouter.ts index 5855941a6d..bacbe1f290 100644 --- a/src/commands/auth-choice.apply.openrouter.ts +++ b/src/commands/auth-choice.apply.openrouter.ts @@ -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 { @@ -20,15 +21,7 @@ export async function applyAuthChoiceOpenRouter( ): Promise { 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 noteAgentModel = createAuthChoiceAgentModelNoter(params); const store = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false }); const profileOrder = resolveAuthProfileOrder({