@@ -15,6 +15,18 @@ export type ApiConfiguration = {
1515 is_pinned ?: boolean
1616}
1717
18+ export type ConfigApiConfigurationFormat = {
19+ providerName : string
20+ model : string
21+ reasoningEffort ?: string
22+ isPinned ?: boolean
23+ isDefaultForCodeAtCursor ?: boolean
24+ isDefaultForIntelligentFileSearch ?: boolean
25+ isDefaultForPatchRepair ?: boolean
26+ isDefaultForCommitMessages ?: boolean
27+ isDefaultForVoiceInput ?: boolean
28+ }
29+
1830export const get_api_configuration_id = (
1931 api_configuration : ApiConfiguration
2032) : string => {
@@ -139,7 +151,7 @@ export class ModelProvidersManager {
139151 public async get_api_configurations ( ) : Promise < ApiConfiguration [ ] > {
140152 await this . _load_promise
141153 const config = vscode . workspace . getConfiguration ( 'codeWebChat' )
142- const settings_configs = config . get < any [ ] > ( 'apiConfigurations' , [ ] )
154+ const settings_configs = config . get < ConfigApiConfigurationFormat [ ] > ( 'apiConfigurations' , [ ] )
143155
144156 const api_configurations : ApiConfiguration [ ] = settings_configs . map (
145157 ( sc ) => {
@@ -159,13 +171,13 @@ export class ModelProvidersManager {
159171
160172 public async save_api_configurations ( api_configurations : ApiConfiguration [ ] ) {
161173 const config = vscode . workspace . getConfiguration ( 'codeWebChat' )
162- const old_settings_configs = config . get < any [ ] > ( 'apiConfigurations' , [ ] )
174+ const old_settings_configs = config . get < ConfigApiConfigurationFormat [ ] > ( 'apiConfigurations' , [ ] )
163175
164176 const new_settings_configs = api_configurations . map ( ( c ) => {
165177 const old_config = old_settings_configs . find ( ( oldC ) =>
166178 this . _are_api_configurations_effectively_equal ( oldC , c )
167179 )
168- const new_config : any = {
180+ const new_config : ConfigApiConfigurationFormat = {
169181 providerName : c . model_provider_name ,
170182 model : c . model
171183 }
@@ -194,7 +206,7 @@ export class ModelProvidersManager {
194206 }
195207
196208 private _are_api_configurations_effectively_equal (
197- settings_config : any ,
209+ settings_config : ConfigApiConfigurationFormat ,
198210 api_configuration : ApiConfiguration
199211 ) : boolean {
200212 return (
@@ -206,10 +218,10 @@ export class ModelProvidersManager {
206218 }
207219
208220 private _get_default_api_configuration_from_settings (
209- default_key : string
221+ default_key : keyof ConfigApiConfigurationFormat
210222 ) : ApiConfiguration | undefined {
211223 const config = vscode . workspace . getConfiguration ( 'codeWebChat' )
212- const settings_configs = config . get < any [ ] > ( 'apiConfigurations' , [ ] )
224+ const settings_configs = config . get < ConfigApiConfigurationFormat [ ] > ( 'apiConfigurations' , [ ] )
213225 const default_config_from_settings = settings_configs . find (
214226 ( c ) => c [ default_key ]
215227 )
@@ -229,11 +241,11 @@ export class ModelProvidersManager {
229241 }
230242
231243 private async _set_default_api_configuration_in_settings (
232- default_key : string ,
244+ default_key : keyof ConfigApiConfigurationFormat ,
233245 config_to_set : ApiConfiguration | null
234246 ) {
235247 const config = vscode . workspace . getConfiguration ( 'codeWebChat' )
236- const settings_configs = config . get < any [ ] > ( 'apiConfigurations' , [ ] )
248+ const settings_configs = config . get < ConfigApiConfigurationFormat [ ] > ( 'apiConfigurations' , [ ] )
237249
238250 const new_settings_configs = settings_configs . map ( ( c ) => {
239251 const is_default =
@@ -242,7 +254,7 @@ export class ModelProvidersManager {
242254
243255 const new_c = { ...c }
244256 if ( is_default ) {
245- new_c [ default_key ] = true
257+ ( new_c as any ) [ default_key ] = true
246258 } else {
247259 delete new_c [ default_key ]
248260 }
0 commit comments