Skip to content

Commit 1529958

Browse files
committed
refactor(models): reuse normalized provider lookup
1 parent 7d3bc4d commit 1529958

1 file changed

Lines changed: 5 additions & 19 deletions

File tree

src/commands/models/list.status-command.ts

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/** Implementation of `openclaw models status`. */
22
import path from "node:path";
3+
import { findNormalizedProviderValue } from "@openclaw/model-catalog-core/provider-id";
34
import { normalizeOptionalString } from "@openclaw/normalization-core/string-coerce";
45
import { colorize, theme } from "../../../packages/terminal-core/src/theme.js";
56
import {
@@ -572,21 +573,6 @@ export async function modelsStatusCommand(
572573
};
573574
const resolveProviderAuthHealthId = (provider: string): string =>
574575
resolveProviderIdForAuth(provider, envLookupParams);
575-
const resolveStatusAuthOrder = (
576-
order: Record<string, string[]> | undefined,
577-
provider: string,
578-
): string[] | undefined => {
579-
if (!order) {
580-
return undefined;
581-
}
582-
const providerKey = normalizeProviderId(provider);
583-
for (const [key, value] of Object.entries(order)) {
584-
if (normalizeProviderId(key) === providerKey) {
585-
return value;
586-
}
587-
}
588-
return undefined;
589-
};
590576
const listRuntimeAuthProviderCandidates = (
591577
provider: string,
592578
options?: { includeLegacyOpenAICodex?: boolean },
@@ -613,10 +599,10 @@ export async function modelsStatusCommand(
613599
const providerKey = normalizeProviderId(provider);
614600
const providerAuthKey = resolveProviderAuthHealthId(providerKey);
615601
const explicitOrder =
616-
resolveStatusAuthOrder(store.order, providerAuthKey) ??
617-
resolveStatusAuthOrder(store.order, providerKey) ??
618-
resolveStatusAuthOrder(cfg.auth?.order, providerAuthKey) ??
619-
resolveStatusAuthOrder(cfg.auth?.order, providerKey);
602+
findNormalizedProviderValue(store.order, providerAuthKey) ??
603+
findNormalizedProviderValue(store.order, providerKey) ??
604+
findNormalizedProviderValue(cfg.auth?.order, providerAuthKey) ??
605+
findNormalizedProviderValue(cfg.auth?.order, providerKey);
620606
const isEligibleOrHealthRescued = (profileId: string): boolean => {
621607
const credential = store.profiles[profileId];
622608
if (!credential) {

0 commit comments

Comments
 (0)