refactor(models): share primary/fallback merge

This commit is contained in:
Peter Steinberger
2026-02-15 17:13:09 +00:00
parent 3ce0e80f57
commit cbf6ee3a64
5 changed files with 64 additions and 62 deletions

View File

@@ -153,6 +153,22 @@ export function resolveKnownAgentId(params: {
return agentId;
}
export type PrimaryFallbackConfig = { primary?: string; fallbacks?: string[] };
export function mergePrimaryFallbackConfig(
existing: PrimaryFallbackConfig | undefined,
patch: { primary?: string; fallbacks?: string[] },
): PrimaryFallbackConfig {
const next: PrimaryFallbackConfig = { ...existing };
if (patch.primary !== undefined) {
next.primary = patch.primary;
}
if (patch.fallbacks !== undefined) {
next.fallbacks = patch.fallbacks;
}
return next;
}
export { modelKey };
export { DEFAULT_MODEL, DEFAULT_PROVIDER };