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:
parent
8873896432
commit
17d43672ad
@ -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>>
|
||||||
|
|||||||
@ -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,
|
||||||
|
|||||||
@ -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"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user