@@ -12,7 +12,6 @@ import * as ModelsDev from "@opencode-ai/core/models"
1212import { Auth } from "../auth"
1313import { Env } from "../env"
1414import { InstallationVersion } from "@opencode-ai/core/installation/version"
15- import { Flag } from "@opencode-ai/core/flag/flag"
1615import { iife } from "@/util/iife"
1716import { Global } from "@opencode-ai/core/global"
1817import path from "path"
@@ -27,6 +26,7 @@ import { optionalOmitUndefined } from "@opencode-ai/core/schema"
2726import * as ProviderTransform from "./transform"
2827import { ModelID , ProviderID } from "./schema"
2928import { ModelStatus } from "./model-status"
29+ import { RuntimeFlags } from "@/effect/runtime-flags"
3030
3131const log = Log . create ( { service : "provider" } )
3232
@@ -1127,18 +1127,18 @@ export function fromModelsDevProvider(provider: ModelsDev.Provider): Info {
11271127 }
11281128}
11291129
1130- function suggestionModelIDs ( provider : Info | undefined ) {
1130+ function suggestionModelIDs ( provider : Info | undefined , enableExperimentalModels : boolean ) {
11311131 if ( ! provider ) return [ ]
11321132 return Object . keys ( provider . models ) . filter ( ( id ) => {
11331133 const model = provider . models [ id ]
11341134 if ( model . status === "deprecated" ) return false
1135- if ( model . status === "alpha" && ! Flag . OPENCODE_ENABLE_EXPERIMENTAL_MODELS ) return false
1135+ if ( model . status === "alpha" && ! enableExperimentalModels ) return false
11361136 return true
11371137 } )
11381138}
11391139
1140- function modelSuggestions ( provider : Info | undefined , modelID : ModelID ) {
1141- const available = suggestionModelIDs ( provider )
1140+ function modelSuggestions ( provider : Info | undefined , modelID : ModelID , enableExperimentalModels : boolean ) {
1141+ const available = suggestionModelIDs ( provider , enableExperimentalModels )
11421142 const fuzzy = fuzzysort . go ( modelID , available , { limit : 3 , threshold : - 10000 } ) . map ( ( m ) => m . target )
11431143 if ( fuzzy . length ) return fuzzy
11441144 const query = modelID
@@ -1159,7 +1159,7 @@ function modelSuggestions(provider: Info | undefined, modelID: ModelID) {
11591159 . map ( ( item ) => item . id )
11601160}
11611161
1162- const layer = Layer . effect (
1162+ export const layer = Layer . effect (
11631163 Service ,
11641164 Effect . gen ( function * ( ) {
11651165 const fs = yield * AppFileSystem . Service
@@ -1168,6 +1168,7 @@ const layer = Layer.effect(
11681168 const env = yield * Env . Service
11691169 const plugin = yield * Plugin . Service
11701170 const modelsDevSvc = yield * ModelsDev . Service
1171+ const runtimeFlags = yield * RuntimeFlags . Service
11711172
11721173 const state = yield * InstanceState . make < State > ( ( ) =>
11731174 Effect . gen ( function * ( ) {
@@ -1460,7 +1461,7 @@ const layer = Layer.effect(
14601461 ( providerID === ProviderID . openrouter && modelID === "openai/gpt-5-chat" )
14611462 )
14621463 delete provider . models [ modelID ]
1463- if ( model . status === "alpha" && ! Flag . OPENCODE_ENABLE_EXPERIMENTAL_MODELS ) delete provider . models [ modelID ]
1464+ if ( model . status === "alpha" && ! runtimeFlags . enableExperimentalModels ) delete provider . models [ modelID ]
14641465 if ( model . status === "deprecated" ) delete provider . models [ modelID ]
14651466 if (
14661467 ( configProvider ?. blacklist && configProvider . blacklist . includes ( modelID ) ) ||
@@ -1656,7 +1657,7 @@ const layer = Layer.effect(
16561657 if ( ! provider ) {
16571658 const catalogProvider = s . catalog [ providerID ]
16581659 const suggestions = catalogProvider
1659- ? modelSuggestions ( catalogProvider , modelID )
1660+ ? modelSuggestions ( catalogProvider , modelID , runtimeFlags . enableExperimentalModels )
16601661 : fuzzysort
16611662 . go ( providerID , Object . keys ( { ...s . catalog , ...s . providers } ) , { limit : 3 , threshold : - 10000 } )
16621663 . map ( ( m ) => m . target )
@@ -1665,8 +1666,10 @@ const layer = Layer.effect(
16651666
16661667 const info = provider . models [ modelID ]
16671668 if ( ! info ) {
1668- const current = modelSuggestions ( provider , modelID )
1669- const suggestions = current . length ? current : modelSuggestions ( s . catalog [ providerID ] , modelID )
1669+ const current = modelSuggestions ( provider , modelID , runtimeFlags . enableExperimentalModels )
1670+ const suggestions = current . length
1671+ ? current
1672+ : modelSuggestions ( s . catalog [ providerID ] , modelID , runtimeFlags . enableExperimentalModels )
16701673 return yield * new ModelNotFoundError ( { providerID, modelID, suggestions } )
16711674 }
16721675 return info
@@ -1814,6 +1817,7 @@ export const defaultLayer = Layer.suspend(() =>
18141817 Layer . provide ( Auth . defaultLayer ) ,
18151818 Layer . provide ( Plugin . defaultLayer ) ,
18161819 Layer . provide ( ModelsDev . defaultLayer ) ,
1820+ Layer . provide ( RuntimeFlags . defaultLayer ) ,
18171821 ) ,
18181822)
18191823
0 commit comments