mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 13:21:25 +00:00
Fix: Add type safety to models status command (#16395)
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: 1554137ae3
Co-authored-by: BinHPdev <219093083+BinHPdev@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
@@ -107,7 +107,7 @@ export async function modelsStatusCommand(
|
||||
const imageFallbacks = typeof imageConfig === "object" ? (imageConfig?.fallbacks ?? []) : [];
|
||||
const aliases = Object.entries(cfg.agents?.defaults?.models ?? {}).reduce<Record<string, string>>(
|
||||
(acc, [key, entry]) => {
|
||||
const alias = entry?.alias?.trim();
|
||||
const alias = typeof entry?.alias === "string" ? entry.alias.trim() : undefined;
|
||||
if (alias) {
|
||||
acc[alias] = key;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ export async function modelsStatusCommand(
|
||||
);
|
||||
const providersFromConfig = new Set(
|
||||
Object.keys(cfg.models?.providers ?? {})
|
||||
.map((p) => p.trim())
|
||||
.map((p) => (typeof p === "string" ? p.trim() : ""))
|
||||
.filter(Boolean),
|
||||
);
|
||||
const providersFromModels = new Set<string>();
|
||||
@@ -176,7 +176,7 @@ export async function modelsStatusCommand(
|
||||
...providersFromEnv,
|
||||
]),
|
||||
)
|
||||
.map((p) => p.trim())
|
||||
.map((p) => (typeof p === "string" ? p.trim() : ""))
|
||||
.filter(Boolean)
|
||||
.toSorted((a, b) => a.localeCompare(b));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user