MCPcopy
hub / github.com/coder/mux / normalizeModelInput

Function normalizeModelInput

src/common/utils/ai/normalizeModelInput.ts:14–34  ·  view source on GitHub ↗
(raw: string | null | undefined)

Source from the content-addressed store, hash-verified

12
13/** Normalize user-provided model input (alias resolution + gateway migration + format validation). */
14export function normalizeModelInput(raw: string | null | undefined): ModelInputResult {
15 const trimmed = typeof raw === "string" ? raw.trim() : "";
16 if (!trimmed) {
17 return { model: null, isAlias: false };
18 }
19
20 const resolved = resolveModelAlias(trimmed);
21 const isAlias = resolved !== trimmed;
22 const selectedModel = normalizeSelectedModel(resolved);
23
24 if (!isValidModelFormat(selectedModel)) {
25 return { model: null, isAlias, error: "invalid-format" };
26 }
27
28 const separatorIndex = selectedModel.indexOf(":");
29 if (selectedModel.slice(separatorIndex + 1).startsWith(":")) {
30 return { model: null, isAlias, error: "invalid-format" };
31 }
32
33 return { model: selectedModel, isAlias };
34}

Callers 9

processSlashCommandFunction · 0.90
handleCompactCommandFunction · 0.90
parseOneshotCommandKeyFunction · 0.90
registry.tsFile · 0.90
useCreationWorkspaceFunction · 0.90
parseTaskAiOverridesFunction · 0.90
normalizeModelForCommandFunction · 0.90

Calls 3

resolveModelAliasFunction · 0.90
normalizeSelectedModelFunction · 0.90
isValidModelFormatFunction · 0.90

Tested by

no test coverage detected