mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-24 03:15:46 -06:00
32c84b0f41
* feat(skills): capture reusable experience safely * feat(skills): review completed work for reusable learning * docs(skills): explain self-learning * docs: clarify self-learning runtime scope * fix(skills): harden autonomous workshop reviews * test(skills): align review prompt fixture
32 lines
1001 B
TypeScript
32 lines
1001 B
TypeScript
import {
|
|
normalizeLowercaseStringOrEmpty,
|
|
normalizeOptionalLowercaseString,
|
|
} from "@openclaw/normalization-core/string-coerce";
|
|
|
|
export function isApplyPatchAllowedForModel(params: {
|
|
modelProvider?: string;
|
|
modelId?: string;
|
|
allowModels?: string[];
|
|
}) {
|
|
const allowModels = Array.isArray(params.allowModels) ? params.allowModels : [];
|
|
if (allowModels.length === 0) {
|
|
return true;
|
|
}
|
|
const modelId = params.modelId?.trim();
|
|
if (!modelId) {
|
|
return false;
|
|
}
|
|
const normalizedModelId = normalizeLowercaseStringOrEmpty(modelId);
|
|
const provider = normalizeOptionalLowercaseString(params.modelProvider);
|
|
const normalizedFull =
|
|
provider && !normalizedModelId.includes("/")
|
|
? `${provider}/${normalizedModelId}`
|
|
: normalizedModelId;
|
|
return allowModels.some((entry) => {
|
|
const normalized = normalizeOptionalLowercaseString(entry);
|
|
return Boolean(
|
|
normalized && (normalized === normalizedModelId || normalized === normalizedFull),
|
|
);
|
|
});
|
|
}
|