mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 14:10:51 +00:00
fix: tighten model catalog manifest normalization
This commit is contained in:
@@ -505,6 +505,20 @@ describe("loadPluginManifestRegistry", () => {
|
||||
output: 2.5,
|
||||
cacheRead: 0.15,
|
||||
tieredPricing: [
|
||||
{
|
||||
input: 0.6,
|
||||
output: 2.5,
|
||||
cacheRead: 0.15,
|
||||
cacheWrite: 0.6,
|
||||
range: [0, "bad"],
|
||||
},
|
||||
{
|
||||
input: 0.6,
|
||||
output: 2.5,
|
||||
cacheRead: 0.15,
|
||||
cacheWrite: 0.6,
|
||||
range: [0, -1],
|
||||
},
|
||||
{
|
||||
input: 0.6,
|
||||
output: 2.5,
|
||||
@@ -516,6 +530,7 @@ describe("loadPluginManifestRegistry", () => {
|
||||
},
|
||||
compat: {
|
||||
supportsTools: true,
|
||||
supportedReasoningEfforts: ["low", "medium"],
|
||||
supportsStore: "yes",
|
||||
unknownFlag: true,
|
||||
},
|
||||
@@ -592,6 +607,7 @@ describe("loadPluginManifestRegistry", () => {
|
||||
},
|
||||
compat: {
|
||||
supportsTools: true,
|
||||
supportedReasoningEfforts: ["low", "medium"],
|
||||
},
|
||||
status: "available",
|
||||
tags: ["default"],
|
||||
|
||||
@@ -50,8 +50,8 @@ export type PluginManifestModelCatalogStatus = "available" | "preview" | "deprec
|
||||
export type PluginManifestModelCatalogTieredCost = {
|
||||
input: number;
|
||||
output: number;
|
||||
cacheRead?: number;
|
||||
cacheWrite?: number;
|
||||
cacheRead: number;
|
||||
cacheWrite: number;
|
||||
range: [number, number] | [number];
|
||||
};
|
||||
|
||||
@@ -432,9 +432,9 @@ function normalizeStringMap(value: unknown): Record<string, string> | undefined
|
||||
const normalized: Record<string, string> = {};
|
||||
for (const [rawKey, rawValue] of Object.entries(value)) {
|
||||
const key = normalizeSafeRecordKey(rawKey);
|
||||
const value = normalizeOptionalString(rawValue) ?? "";
|
||||
if (key && value) {
|
||||
normalized[key] = value;
|
||||
const strValue = normalizeOptionalString(rawValue) ?? "";
|
||||
if (key && strValue) {
|
||||
normalized[key] = strValue;
|
||||
}
|
||||
}
|
||||
return Object.keys(normalized).length > 0 ? normalized : undefined;
|
||||
@@ -728,15 +728,17 @@ function normalizeModelCatalogTieredCost(
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
const rangeValues = entry.range
|
||||
.map((rangeValue) => normalizeModelCatalogNumber(rangeValue))
|
||||
.filter((rangeValue): rangeValue is number => rangeValue !== undefined);
|
||||
if (entry.range.length < 1 || entry.range.length > 2) {
|
||||
continue;
|
||||
}
|
||||
const rangeValues = entry.range.map((rangeValue) => normalizeModelCatalogNumber(rangeValue));
|
||||
if (rangeValues.some((rangeValue) => rangeValue === undefined)) {
|
||||
continue;
|
||||
}
|
||||
const range =
|
||||
rangeValues.length === 1
|
||||
? ([rangeValues[0]] as [number])
|
||||
: rangeValues.length >= 2
|
||||
? ([rangeValues[0], rangeValues[1]] as [number, number])
|
||||
: undefined;
|
||||
: ([rangeValues[0], rangeValues[1]] as [number, number]);
|
||||
if (!range) {
|
||||
continue;
|
||||
}
|
||||
@@ -807,6 +809,7 @@ function normalizeModelCatalogCompat(value: unknown): ModelCompatConfig | undefi
|
||||
|
||||
const stringListFields = [
|
||||
"visibleReasoningDetailTypes",
|
||||
"supportedReasoningEfforts",
|
||||
"unsupportedToolSchemaKeywords",
|
||||
] as const;
|
||||
for (const field of stringListFields) {
|
||||
|
||||
Reference in New Issue
Block a user