mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-23 15:51:10 +00:00
* feat(openai): add provider-owned route facts * fix(openai): harden provider route facts * test(codex): update rebased auth fixtures * chore: leave release notes to release workflow * fix(openai): align route auth with current contracts * test(openai): align route and shard expectations * test(openai): satisfy route fixture contracts * fix(openai): preserve direct profile forwarding * test(models): complete route auth mocks * test(codex): type compaction factory mock * fix(openai): preserve provider-native model ids * test(agents): align route auth fixtures * style(agents): format route integrations * test(plugin-sdk): pin current surface counts
46 lines
1.8 KiB
TypeScript
46 lines
1.8 KiB
TypeScript
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
|
import { modelKey } from "../shared/model-key.js";
|
|
|
|
type ModelExtraParamSources = {
|
|
defaultParams?: Record<string, unknown>;
|
|
modelParams?: Record<string, unknown>;
|
|
agentParams?: Record<string, unknown>;
|
|
};
|
|
|
|
function legacyModelKey(provider: string, modelId: string): string | undefined {
|
|
const rawKey = `${provider.trim()}/${modelId.trim()}`;
|
|
const canonicalKey = modelKey(provider, modelId);
|
|
return rawKey === canonicalKey ? undefined : rawKey;
|
|
}
|
|
|
|
/** Resolves the config records merged into one model request. */
|
|
export function resolveModelExtraParamSources(params: {
|
|
config?: OpenClawConfig;
|
|
provider: string;
|
|
modelId?: string;
|
|
agentId?: string;
|
|
}): ModelExtraParamSources {
|
|
const defaultParams = params.config?.agents?.defaults?.params;
|
|
const configuredModels = params.config?.agents?.defaults?.models;
|
|
const canonicalKey = params.modelId ? modelKey(params.provider, params.modelId) : undefined;
|
|
const legacyKey = params.modelId ? legacyModelKey(params.provider, params.modelId) : undefined;
|
|
const modelParams = canonicalKey
|
|
? (configuredModels?.[canonicalKey]?.params ??
|
|
(legacyKey ? configuredModels?.[legacyKey]?.params : undefined))
|
|
: undefined;
|
|
const agentParams = params.agentId
|
|
? params.config?.agents?.list?.find((agent) => agent.id === params.agentId)?.params
|
|
: undefined;
|
|
return { defaultParams, modelParams, agentParams };
|
|
}
|
|
|
|
/** Returns whether embedded OpenClaw would apply authored request parameters. */
|
|
export function hasModelExtraParams(
|
|
params: Parameters<typeof resolveModelExtraParamSources>[0],
|
|
): boolean {
|
|
const sources = resolveModelExtraParamSources(params);
|
|
return [sources.defaultParams, sources.modelParams, sources.agentParams].some(
|
|
(source) => source !== undefined && Object.keys(source).length > 0,
|
|
);
|
|
}
|