mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-06 14:51:08 +00:00
fix(providers): stabilize runtime normalization hooks
This commit is contained in:
@@ -412,7 +412,25 @@ export function normalizeProviderConfigWithPlugin(params: {
|
||||
env?: NodeJS.ProcessEnv;
|
||||
context: ProviderNormalizeConfigContext;
|
||||
}): ModelProviderConfig | undefined {
|
||||
return resolveProviderHookPlugin(params)?.normalizeConfig?.(params.context) ?? undefined;
|
||||
const hasConfigChange = (normalized: ModelProviderConfig) =>
|
||||
normalized !== params.context.providerConfig;
|
||||
const matchedPlugin = resolveProviderHookPlugin(params);
|
||||
const normalizedMatched = matchedPlugin?.normalizeConfig?.(params.context);
|
||||
if (normalizedMatched && hasConfigChange(normalizedMatched)) {
|
||||
return normalizedMatched;
|
||||
}
|
||||
|
||||
for (const candidate of resolveProviderPluginsForHooks(params)) {
|
||||
if (!candidate.normalizeConfig || candidate === matchedPlugin) {
|
||||
continue;
|
||||
}
|
||||
const normalized = candidate.normalizeConfig(params.context);
|
||||
if (normalized && hasConfigChange(normalized)) {
|
||||
return normalized;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function applyProviderNativeStreamingUsageCompatWithPlugin(params: {
|
||||
|
||||
Reference in New Issue
Block a user