refactor(commands): dedupe auth choice agent model notes

This commit is contained in:
Peter Steinberger
2026-02-15 13:46:13 +00:00
parent 9d7113c74c
commit 26a831e2c3
3 changed files with 19 additions and 18 deletions

View File

@@ -0,0 +1,15 @@
import type { ApplyAuthChoiceParams } from "./auth-choice.apply.js";
export function createAuthChoiceAgentModelNoter(
params: ApplyAuthChoiceParams,
): (model: string) => Promise<void> {
return async (model: string) => {
if (!params.agentId) {
return;
}
await params.prompter.note(
`Default model set to ${model} for agent "${params.agentId}".`,
"Model configured",
);
};
}

View File

@@ -9,6 +9,7 @@ import {
normalizeApiKeyInput,
validateApiKeyInput,
} from "./auth-choice.api-key.js";
import { createAuthChoiceAgentModelNoter } from "./auth-choice.apply-helpers.js";
import { applyDefaultModelChoice } from "./auth-choice.default-model.js";
import { ensureModelAllowlistEntry } from "./model-allowlist.js";
import {
@@ -27,15 +28,7 @@ export async function applyAuthChoiceHuggingface(
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 hasCredential = false;
let hfKey = "";

View File

@@ -5,6 +5,7 @@ import {
normalizeApiKeyInput,
validateApiKeyInput,
} from "./auth-choice.api-key.js";
import { createAuthChoiceAgentModelNoter } from "./auth-choice.apply-helpers.js";
import { applyDefaultModelChoice } from "./auth-choice.default-model.js";
import {
applyAuthProfileConfig,
@@ -23,15 +24,7 @@ export async function applyAuthChoiceXAI(
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 hasCredential = false;
const optsKey = params.opts?.xaiApiKey?.trim();