mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 16:00:44 +00:00
28 lines
867 B
TypeScript
28 lines
867 B
TypeScript
import { normalizeProviderId } from "../agents/provider-id.js";
|
|
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
|
|
|
export function resolveProviderConfigApiOwnerHint(params: {
|
|
provider: string;
|
|
config?: OpenClawConfig;
|
|
}): string | undefined {
|
|
const providers = params.config?.models?.providers;
|
|
if (!providers) {
|
|
return undefined;
|
|
}
|
|
const normalizedProvider = normalizeProviderId(params.provider);
|
|
if (!normalizedProvider) {
|
|
return undefined;
|
|
}
|
|
const providerConfig =
|
|
providers[params.provider] ??
|
|
Object.entries(providers).find(
|
|
([candidateId]) => normalizeProviderId(candidateId) === normalizedProvider,
|
|
)?.[1];
|
|
const api =
|
|
typeof providerConfig?.api === "string" ? normalizeProviderId(providerConfig.api) : "";
|
|
if (!api || api === normalizedProvider) {
|
|
return undefined;
|
|
}
|
|
return api;
|
|
}
|