mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-13 18:21:27 +00:00
30 lines
920 B
TypeScript
30 lines
920 B
TypeScript
import { normalizeOptionalString, resolvePrimaryStringValue } from "../shared/string-coerce.js";
|
|
import type { AgentModelConfig } from "./types.agents-shared.js";
|
|
|
|
type AgentModelListLike = {
|
|
primary?: string;
|
|
fallbacks?: string[];
|
|
};
|
|
|
|
export function resolveAgentModelPrimaryValue(model?: AgentModelConfig): string | undefined {
|
|
return resolvePrimaryStringValue(model);
|
|
}
|
|
|
|
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 = normalizeOptionalString(model);
|
|
return primary ? { primary } : undefined;
|
|
}
|
|
if (!model || typeof model !== "object") {
|
|
return undefined;
|
|
}
|
|
return model;
|
|
}
|