refactor(shared): add normalizeFallbackModels utility function

Add shared utility to normalize fallback_models config values.

Handles both single string and array inputs consistently.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
um1ng
2026-02-05 23:15:31 +09:00
committed by YeonGyu-Kim
parent bf02d57ffb
commit 5822d8b8f5
3 changed files with 13 additions and 0 deletions
+11
View File
@@ -7,6 +7,17 @@ export type ModelResolutionInput = {
systemDefault?: string
}
/**
* Normalizes fallback_models to an array.
* Handles single string or array input, returns undefined for falsy values.
*/
export function normalizeFallbackModels(
fallbackModels: string | string[] | undefined | null
): string[] | undefined {
if (!fallbackModels) return undefined
return Array.isArray(fallbackModels) ? fallbackModels : [fallbackModels]
}
export type ModelSource =
| "override"
| "category-default"