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> & {
prompt_append?: string
variant?: string
fallback_models?: string | string[]
}
export type AgentOverrides = Partial<Record<OverridableAgentName, AgentOverrideConfig>>

View File

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

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"