mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 17:38:27 +00:00
chore: apply local workspace updates (#9911)
* chore: apply local workspace updates * fix: resolve prep findings after rebase (#9898) (thanks @gumadeiras) * refactor: centralize model allowlist normalization (#9898) (thanks @gumadeiras) * fix: guard model allowlist initialization (#9911) * docs: update changelog scope for #9911 * docs: remove model names from changelog entry (#9911) * fix: satisfy type-aware lint in model allowlist (#9911)
This commit is contained in:
committed by
GitHub
parent
93b450349f
commit
4629054403
41
src/commands/model-allowlist.ts
Normal file
41
src/commands/model-allowlist.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { DEFAULT_PROVIDER } from "../agents/defaults.js";
|
||||
import { resolveAllowlistModelKey } from "../agents/model-selection.js";
|
||||
|
||||
export function ensureModelAllowlistEntry(params: {
|
||||
cfg: OpenClawConfig;
|
||||
modelRef: string;
|
||||
defaultProvider?: string;
|
||||
}): OpenClawConfig {
|
||||
const rawModelRef = params.modelRef.trim();
|
||||
if (!rawModelRef) {
|
||||
return params.cfg;
|
||||
}
|
||||
|
||||
const models = { ...params.cfg.agents?.defaults?.models };
|
||||
const keySet = new Set<string>([rawModelRef]);
|
||||
const canonicalKey = resolveAllowlistModelKey(
|
||||
rawModelRef,
|
||||
params.defaultProvider ?? DEFAULT_PROVIDER,
|
||||
);
|
||||
if (canonicalKey) {
|
||||
keySet.add(canonicalKey);
|
||||
}
|
||||
|
||||
for (const key of keySet) {
|
||||
models[key] = {
|
||||
...models[key],
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
...params.cfg,
|
||||
agents: {
|
||||
...params.cfg.agents,
|
||||
defaults: {
|
||||
...params.cfg.agents?.defaults,
|
||||
models,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user