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 8873896432
commit 17d43672ad
3 changed files with 13 additions and 0 deletions

View File

@ -100,6 +100,7 @@ export type AgentName = BuiltinAgentName
export type AgentOverrideConfig = Partial<AgentConfig> & { export type AgentOverrideConfig = Partial<AgentConfig> & {
prompt_append?: string prompt_append?: string
variant?: string variant?: string
fallback_models?: string | string[]
} }
export type AgentOverrides = Partial<Record<OverridableAgentName, AgentOverrideConfig>> export type AgentOverrides = Partial<Record<OverridableAgentName, AgentOverrideConfig>>

View File

@ -34,6 +34,7 @@ export * from "./system-directive"
export * from "./agent-tool-restrictions" export * from "./agent-tool-restrictions"
export * from "./model-requirements" export * from "./model-requirements"
export * from "./model-resolver" export * from "./model-resolver"
export { normalizeFallbackModels } from "./model-resolver"
export { resolveModelPipeline } from "./model-resolution-pipeline" export { resolveModelPipeline } from "./model-resolution-pipeline"
export type { export type {
ModelResolutionRequest, ModelResolutionRequest,

View File

@ -7,6 +7,17 @@ export type ModelResolutionInput = {
systemDefault?: string 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 = export type ModelSource =
| "override" | "override"
| "category-default" | "category-default"