From 1f4dab2c37071d90891c30c6e51c522e30f6488c Mon Sep 17 00:00:00 2001 From: Shakker Date: Sat, 25 Apr 2026 02:50:34 +0100 Subject: [PATCH] fix: tighten model catalog manifest normalization --- src/plugins/manifest-registry.test.ts | 16 ++++++++++++++++ src/plugins/manifest.ts | 25 ++++++++++++++----------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/plugins/manifest-registry.test.ts b/src/plugins/manifest-registry.test.ts index 10adbcd9ed2..7ae3c9c496b 100644 --- a/src/plugins/manifest-registry.test.ts +++ b/src/plugins/manifest-registry.test.ts @@ -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"], diff --git a/src/plugins/manifest.ts b/src/plugins/manifest.ts index 49a556740f2..73dfbd448ef 100644 --- a/src/plugins/manifest.ts +++ b/src/plugins/manifest.ts @@ -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 | undefined const normalized: Record = {}; 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) {