@@ -982,21 +982,6 @@ const ProviderInterleaved = Schema.Union([
982982 } ) ,
983983] )
984984
985- const ProviderReasoningOption = Schema . Union ( [
986- Schema . Struct ( {
987- type : Schema . Literal ( "effort" ) ,
988- values : Schema . Array ( Schema . NullOr ( Schema . String ) ) ,
989- } ) ,
990- Schema . Struct ( {
991- type : Schema . Literal ( "toggle" ) ,
992- } ) ,
993- Schema . Struct ( {
994- type : Schema . Literal ( "budget_tokens" ) ,
995- min : optional ( Schema . Finite ) ,
996- max : optional ( Schema . Finite ) ,
997- } ) ,
998- ] )
999-
1000985const ProviderCapabilities = Schema . Struct ( {
1001986 temperature : Schema . Boolean ,
1002987 reasoning : Schema . Boolean ,
@@ -1055,7 +1040,6 @@ export const Model = Schema.Struct({
10551040 options : Schema . Record ( Schema . String , Schema . Any ) ,
10561041 headers : Schema . Record ( Schema . String , Schema . String ) ,
10571042 release_date : Schema . String ,
1058- reasoning_options : optional ( Schema . Array ( ProviderReasoningOption ) ) ,
10591043 variants : optional ( Schema . Record ( Schema . String , Schema . Record ( Schema . String , Schema . Any ) ) ) ,
10601044} ) . annotate ( { identifier : "Model" } )
10611045export type Model = Types . DeepMutable < Schema . Schema . Type < typeof Model > >
@@ -1091,11 +1075,7 @@ export function toPublicInfo(provider: Info): Info {
10911075 JSON . stringify (
10921076 {
10931077 ...provider ,
1094- models : Object . fromEntries (
1095- Object . entries ( provider . models )
1096- . filter ( ( [ , model ] ) => Schema . is ( Model ) ( model ) )
1097- . map ( ( [ id , model ] ) => [ id , publicModel ( model ) ] ) ,
1098- ) ,
1078+ models : Object . fromEntries ( Object . entries ( provider . models ) . filter ( ( [ , model ] ) => Schema . is ( Model ) ( model ) ) ) ,
10991079 } ,
11001080 ( _ , value ) => {
11011081 if ( typeof value === "function" || typeof value === "symbol" || value === undefined ) return undefined
@@ -1223,66 +1203,6 @@ function cost(c: ModelsDev.Model["cost"]): Model["cost"] {
12231203 return result
12241204}
12251205
1226- type ReasoningOption = NonNullable < Model [ "reasoning_options" ] > [ number ]
1227-
1228- function reasoningOptions ( input : unknown ) : Model [ "reasoning_options" ] {
1229- if ( ! Array . isArray ( input ) ) return [ ]
1230- return input . flatMap ( ( option ) => {
1231- const normalized = normalizeReasoningOption ( option )
1232- return normalized ? [ normalized ] : [ ]
1233- } )
1234- }
1235-
1236- function normalizeReasoningOption ( option : unknown ) : ReasoningOption | undefined {
1237- if ( ! isRecord ( option ) ) return
1238- if ( option . type === "effort" ) {
1239- if ( ! Array . isArray ( option . values ) ) return
1240- return {
1241- type : "effort" ,
1242- values : option . values . filter ( ( value ) : value is string | null => value === null || typeof value === "string" ) ,
1243- }
1244- }
1245- if ( option . type === "toggle" ) return { type : "toggle" }
1246- if ( option . type !== "budget_tokens" ) return
1247- const min = typeof option . min === "number" && Number . isFinite ( option . min ) ? option . min : undefined
1248- const max = typeof option . max === "number" && Number . isFinite ( option . max ) ? option . max : undefined
1249- return {
1250- type : "budget_tokens" ,
1251- ...( min === undefined ? { } : { min } ) ,
1252- ...( max === undefined ? { } : { max } ) ,
1253- }
1254- }
1255-
1256- type PublicReasoningOption = NonNullable < import ( "@opencode-ai/sdk/v2" ) . Model [ "reasoning_options" ] > [ number ]
1257-
1258- function publicReasoningOptions ( options : Model [ "reasoning_options" ] ) : PublicReasoningOption [ ] | undefined {
1259- if ( ! options ) return undefined
1260- const next : PublicReasoningOption [ ] = [ ]
1261- for ( const option of options ) {
1262- if ( option . type === "effort" ) {
1263- const values = option . values . filter ( ( value ) : value is string => typeof value === "string" )
1264- if ( values . length > 0 ) next . push ( { type : "effort" , values } )
1265- continue
1266- }
1267- if ( option . type === "toggle" ) {
1268- next . push ( { type : "toggle" } )
1269- continue
1270- }
1271- next . push ( {
1272- type : "budget_tokens" ,
1273- ...( option . min === undefined ? { } : { min : option . min } ) ,
1274- ...( option . max === undefined ? { } : { max : option . max } ) ,
1275- } )
1276- }
1277- return next . length > 0 ? next : undefined
1278- }
1279-
1280- export function publicModel ( model : Model ) : Model {
1281- const reasoning_options = publicReasoningOptions ( model . reasoning_options )
1282- if ( reasoning_options === undefined ) return model
1283- return { ...model , reasoning_options : reasoning_options as Model [ "reasoning_options" ] }
1284- }
1285-
12861206function fromModelsDevModel ( provider : ModelsDev . Provider , model : ModelsDev . Model ) : Model {
12871207 const base : Model = {
12881208 id : ModelV2 . ID . make ( model . id ) ,
@@ -1325,13 +1245,14 @@ function fromModelsDevModel(provider: ModelsDev.Provider, model: ModelsDev.Model
13251245 interleaved : model . interleaved ?? false ,
13261246 } ,
13271247 release_date : model . release_date ?? "" ,
1328- reasoning_options : reasoningOptions ( model . reasoning_options ) ,
13291248 variants : { } ,
13301249 }
13311250
1251+ const variants = ProviderTransform . reasoningVariants ( model , base ) ?? ProviderTransform . variants ( base )
1252+
13321253 return {
13331254 ...base ,
1334- variants : mapValues ( ProviderTransform . variants ( base ) , ( v ) => v ) ,
1255+ variants : mapValues ( variants , ( v ) => v ) ,
13351256 }
13361257}
13371258
@@ -1572,10 +1493,13 @@ const layer = Layer.effect(
15721493 headers : mergeDeep ( existingModel ?. headers ?? { } , model . headers ?? { } ) ,
15731494 family : model . family ?? existingModel ?. family ?? "" ,
15741495 release_date : model . release_date ?? existingModel ?. release_date ?? "" ,
1575- reasoning_options : existingModel ?. reasoning_options ,
15761496 variants : { } ,
15771497 }
1578- const merged = mergeDeep ( ProviderTransform . variants ( parsedModel ) , model . variants ?? { } )
1498+ const variants =
1499+ existingModel ?. api . npm === parsedModel . api . npm
1500+ ? ( existingModel . variants ?? ProviderTransform . variants ( parsedModel ) )
1501+ : ProviderTransform . variants ( parsedModel )
1502+ const merged = mergeDeep ( variants , model . variants ?? { } )
15791503 parsedModel . variants = mapValues (
15801504 pickBy ( merged , ( v ) => ! v . disabled ) ,
15811505 ( v ) => omit ( v , [ "disabled" ] ) ,
@@ -1703,7 +1627,7 @@ const layer = Layer.effect(
17031627 )
17041628 delete provider . models [ modelID ]
17051629
1706- if ( ! model . variants || Object . keys ( model . variants ) . length === 0 ) {
1630+ if ( model . variants === undefined ) {
17071631 model . variants = mapValues ( ProviderTransform . variants ( model ) , ( v ) => v )
17081632 }
17091633
0 commit comments