Merged via /review-pr -> /prepare-pr -> /merge-pr. Prepared head SHA: 0f272b102763736001a82cfda23f35ff2ee9cac8 Co-authored-by: bianbiandashen <16240681+bianbiandashen@users.noreply.github.com> Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com> Reviewed-by: @gumadeiras
37 lines
1011 B
TypeScript
37 lines
1011 B
TypeScript
import type { AgentModelConfig } from "./types.agents-shared.js";
|
|
|
|
type AgentModelListLike = {
|
|
primary?: string;
|
|
fallbacks?: string[];
|
|
};
|
|
|
|
export function resolveAgentModelPrimaryValue(model?: AgentModelConfig): string | undefined {
|
|
if (typeof model === "string") {
|
|
const trimmed = model.trim();
|
|
return trimmed || undefined;
|
|
}
|
|
if (!model || typeof model !== "object") {
|
|
return undefined;
|
|
}
|
|
const primary = model.primary?.trim();
|
|
return primary || undefined;
|
|
}
|
|
|
|
export function resolveAgentModelFallbackValues(model?: AgentModelConfig): string[] {
|
|
if (!model || typeof model !== "object") {
|
|
return [];
|
|
}
|
|
return Array.isArray(model.fallbacks) ? model.fallbacks : [];
|
|
}
|
|
|
|
export function toAgentModelListLike(model?: AgentModelConfig): AgentModelListLike | undefined {
|
|
if (typeof model === "string") {
|
|
const primary = model.trim();
|
|
return primary ? { primary } : undefined;
|
|
}
|
|
if (!model || typeof model !== "object") {
|
|
return undefined;
|
|
}
|
|
return model;
|
|
}
|