@@ -57,6 +57,7 @@ type DiscoveredModel = {
5757 contextWindow ?: number ;
5858 contextTokens ?: number ;
5959 reasoning ?: boolean ;
60+ thinkingLevelMap ?: ModelCatalogEntry [ "thinkingLevelMap" ] ;
6061 input ?: ModelInputType [ ] ;
6162 params ?: ModelCatalogEntry [ "params" ] ;
6263 compat ?: ModelCatalogEntry [ "compat" ] ;
@@ -183,6 +184,7 @@ function clearRouteBoundCatalogMetadata(entry: ModelCatalogEntry): ModelCatalogE
183184 contextWindowDefault : _contextWindowDefault ,
184185 contextTokens : _contextTokens ,
185186 reasoning : _reasoning ,
187+ thinkingLevelMap : _thinkingLevelMap ,
186188 input : _input ,
187189 params : _params ,
188190 compat : _compat ,
@@ -196,7 +198,7 @@ function overlayCatalogMetadata(
196198 base : ModelCatalogEntry ,
197199 overlay : ModelCatalogEntry ,
198200 options ?: {
199- catalogCompatRoute ?: ModelCatalogEntry ;
201+ catalogRoute ?: ModelCatalogEntry ;
200202 preserveBaseCompat ?: boolean ;
201203 preserveBaseName ?: boolean ;
202204 } ,
@@ -207,6 +209,7 @@ function overlayCatalogMetadata(
207209 const routeChanged = catalogRouteChanges ( base , overlay ) ;
208210 const routeBase = routeChanged ? clearRouteBoundCatalogMetadata ( base ) : base ;
209211 const params = mergeCatalogParams ( routeBase . params , overlay . params ) ;
212+ const thinkingLevelMap = overlay . thinkingLevelMap ?? options ?. catalogRoute ?. thinkingLevelMap ;
210213 // Options + default are one normalized unit (default ∈ options): an overlay
211214 // that replaces the options list must also own the default, or a base default
212215 // absent from the new list would leak through the field-by-field merge.
@@ -243,6 +246,7 @@ function overlayCatalogMetadata(
243246 ...( overlay . contextWindow !== undefined ? { contextWindow : overlay . contextWindow } : { } ) ,
244247 ...( overlay . contextTokens !== undefined ? { contextTokens : overlay . contextTokens } : { } ) ,
245248 ...( overlay . reasoning !== undefined ? { reasoning : overlay . reasoning } : { } ) ,
249+ ...( thinkingLevelMap ? { thinkingLevelMap } : { } ) ,
246250 ...( overlay . input !== undefined ? { input : overlay . input } : { } ) ,
247251 ...( params ? { params } : { } ) ,
248252 ...( overlay . mediaInput !== undefined ? { mediaInput : overlay . mediaInput } : { } ) ,
@@ -253,8 +257,8 @@ function overlayCatalogMetadata(
253257 ...( overlay . replacedBy !== undefined ? { replacedBy : overlay . replacedBy } : { } ) ,
254258 compat : options ?. preserveBaseCompat
255259 ? resolveCatalogOwnedModelCompat ( {
256- catalogRoute : options . catalogCompatRoute ?? base ,
257- catalogCompat : ( options . catalogCompatRoute ?? base ) . compat ,
260+ catalogRoute : options . catalogRoute ?? base ,
261+ catalogCompat : ( options . catalogRoute ?? base ) . compat ,
258262 configuredRoute : {
259263 api : overlay . api ?? base . api ,
260264 baseUrl : overlay . baseUrl ?? base . baseUrl ,
@@ -279,7 +283,7 @@ function mergeCatalogEntries(
279283 models : ModelCatalogEntry [ ] ,
280284 entries : ModelCatalogEntry [ ] ,
281285 options ?: {
282- catalogCompatRoutes ?: readonly ModelCatalogEntry [ ] ;
286+ catalogRoutes ?: readonly ModelCatalogEntry [ ] ;
283287 preserveBaseCompat ?: boolean ;
284288 preserveBaseName ?: boolean ;
285289 } ,
@@ -297,16 +301,16 @@ function mergeCatalogEntries(
297301 }
298302 const existing = models . at ( existingIndex ) ;
299303 if ( existing ) {
300- // The logical row may currently represent a sibling physical route. Compat
301- // must come from the catalog variant selected by config, not that sibling.
302- const catalogCompatRoute = options ?. preserveBaseCompat
303- ? options . catalogCompatRoutes ?. find (
304+ // Logical rows can represent a sibling route; capabilities must come
305+ // from the exact catalog variant selected by config, not that sibling.
306+ const catalogRoute = options ?. preserveBaseCompat
307+ ? options . catalogRoutes ?. find (
304308 ( candidate ) => catalogRouteVariantKey ( candidate ) === catalogRouteVariantKey ( entry ) ,
305309 )
306310 : undefined ;
307311 models [ existingIndex ] = overlayCatalogMetadata ( existing , entry , {
308312 ...options ,
309- catalogCompatRoute ,
313+ catalogRoute ,
310314 } ) ;
311315 }
312316 }
@@ -454,6 +458,9 @@ export function loadManifestModelCatalog(params: {
454458 if ( typeof row . reasoning === "boolean" ) {
455459 entry . reasoning = row . reasoning ;
456460 }
461+ if ( row . thinkingLevelMap ) {
462+ entry . thinkingLevelMap = { ...row . thinkingLevelMap } ;
463+ }
457464 if ( row . input ?. length ) {
458465 entry . input = [ ...row . input ] ;
459466 }
@@ -561,6 +568,7 @@ export async function buildPreparedModelCatalogSnapshot(
561568 contextWindow,
562569 ...( contextTokens !== undefined ? { contextTokens } : { } ) ,
563570 reasoning,
571+ ...( entry . thinkingLevelMap ? { thinkingLevelMap : entry . thinkingLevelMap } : { } ) ,
564572 input,
565573 ...( modelParams ? { params : modelParams } : { } ) ,
566574 compat,
@@ -606,7 +614,7 @@ export async function buildPreparedModelCatalogSnapshot(
606614 if ( configuredModels . length > 0 ) {
607615 const entriesForAugment = [ ...models ] ;
608616 mergeCatalogEntries ( entriesForAugment , configuredModels , {
609- catalogCompatRoutes : routeVariants . entries ,
617+ catalogRoutes : routeVariants . entries ,
610618 preserveBaseCompat : true ,
611619 preserveBaseName : true ,
612620 } ) ;
@@ -692,7 +700,7 @@ export async function buildPreparedModelCatalogSnapshot(
692700 if ( configuredModels . length > 0 ) {
693701 mergeCatalogRouteVariants ( routeVariants , configuredModels , { preserveBaseCompat : true } ) ;
694702 mergeCatalogEntries ( models , configuredModels , {
695- catalogCompatRoutes : routeVariants . entries ,
703+ catalogRoutes : routeVariants . entries ,
696704 preserveBaseCompat : true ,
697705 preserveBaseName : true ,
698706 } ) ;
0 commit comments