openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
40 lines (39 loc) • 1.68 kB
JavaScript
import { l as normalizeOptionalString } from "./string-coerce-CCIiB4H7.mjs";
//#region src/agents/model-selection-display.ts
/**
* Formats selected model references for UI/session display.
*/
/** Resolves the most specific provider/model ref for display. */
function resolveModelDisplayRef(e) {
for (const [t, n] of [["runtimeModel", "runtimeProvider"], ["overrideModel", "overrideProvider"]]) {
const r = normalizeOptionalString(e[t]);
const i = normalizeOptionalString(e[n]);
if (r) return i && !r.includes("/") ? `${i}/${r}` : r;
if (i) return i;
}
return normalizeOptionalString(e.fallbackModel);
}
/** Resolves the model name shown in compact status output. */
function resolveModelDisplayName(e) {
const t = resolveModelDisplayRef(e);
if (!t) return "model n/a";
const n = t.lastIndexOf("/");
if (n >= 0 && n < t.length - 1) return t.slice(n + 1);
return t;
}
/** Resolves session-info model selection from entry, override, and fallback data. */
function resolveSessionInfoModelSelection(e) {
const t = normalizeOptionalString(e.currentProvider) ?? normalizeOptionalString(e.defaultProvider);
const n = normalizeOptionalString(e.currentModel) ?? normalizeOptionalString(e.defaultModel);
if (e.entryProvider !== void 0 || e.entryModel !== void 0) return {
modelProvider: normalizeOptionalString(e.entryProvider) ?? t,
model: normalizeOptionalString(e.entryModel) ?? n
};
const r = normalizeOptionalString(e.overrideModel);
return {
modelProvider: r ? normalizeOptionalString(e.overrideProvider) || t : t,
model: r ?? n
};
}
//#endregion
export { resolveModelDisplayRef as n, resolveSessionInfoModelSelection as r, resolveModelDisplayName as t };