@@ -1310,6 +1310,20 @@ export class ClineProvider implements vscode.WebviewViewProvider {
13101310 }
13111311 break
13121312 }
1313+ case "saveApiConfiguration" :
1314+ if ( message . text && message . apiConfiguration ) {
1315+ try {
1316+ await this . configManager . saveConfig ( message . text , message . apiConfiguration )
1317+ const listApiConfig = await this . configManager . listConfig ( )
1318+ await this . updateGlobalState ( "listApiConfigMeta" , listApiConfig )
1319+ } catch ( error ) {
1320+ this . outputChannel . appendLine (
1321+ `Error save api configuration: ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
1322+ )
1323+ vscode . window . showErrorMessage ( "Failed to save api configuration" )
1324+ }
1325+ }
1326+ break
13131327 case "upsertApiConfiguration" :
13141328 if ( message . text && message . apiConfiguration ) {
13151329 try {
@@ -1354,9 +1368,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
13541368 await this . postStateToWebview ( )
13551369 } catch ( error ) {
13561370 this . outputChannel . appendLine (
1357- `Error create new api configuration: ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
1371+ `Error rename api configuration: ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
13581372 )
1359- vscode . window . showErrorMessage ( "Failed to create api configuration" )
1373+ vscode . window . showErrorMessage ( "Failed to rename api configuration" )
13601374 }
13611375 }
13621376 break
@@ -1639,50 +1653,52 @@ export class ClineProvider implements vscode.WebviewViewProvider {
16391653 requestyModelInfo,
16401654 modelTemperature,
16411655 } = apiConfiguration
1642- await this . updateGlobalState ( "apiProvider" , apiProvider )
1643- await this . updateGlobalState ( "apiModelId" , apiModelId )
1644- await this . storeSecret ( "apiKey" , apiKey )
1645- await this . updateGlobalState ( "glamaModelId" , glamaModelId )
1646- await this . updateGlobalState ( "glamaModelInfo" , glamaModelInfo )
1647- await this . storeSecret ( "glamaApiKey" , glamaApiKey )
1648- await this . storeSecret ( "openRouterApiKey" , openRouterApiKey )
1649- await this . storeSecret ( "awsAccessKey" , awsAccessKey )
1650- await this . storeSecret ( "awsSecretKey" , awsSecretKey )
1651- await this . storeSecret ( "awsSessionToken" , awsSessionToken )
1652- await this . updateGlobalState ( "awsRegion" , awsRegion )
1653- await this . updateGlobalState ( "awsUseCrossRegionInference" , awsUseCrossRegionInference )
1654- await this . updateGlobalState ( "awsProfile" , awsProfile )
1655- await this . updateGlobalState ( "awsUseProfile" , awsUseProfile )
1656- await this . updateGlobalState ( "vertexProjectId" , vertexProjectId )
1657- await this . updateGlobalState ( "vertexRegion" , vertexRegion )
1658- await this . updateGlobalState ( "openAiBaseUrl" , openAiBaseUrl )
1659- await this . storeSecret ( "openAiApiKey" , openAiApiKey )
1660- await this . updateGlobalState ( "openAiModelId" , openAiModelId )
1661- await this . updateGlobalState ( "openAiCustomModelInfo" , openAiCustomModelInfo )
1662- await this . updateGlobalState ( "openAiUseAzure" , openAiUseAzure )
1663- await this . updateGlobalState ( "ollamaModelId" , ollamaModelId )
1664- await this . updateGlobalState ( "ollamaBaseUrl" , ollamaBaseUrl )
1665- await this . updateGlobalState ( "lmStudioModelId" , lmStudioModelId )
1666- await this . updateGlobalState ( "lmStudioBaseUrl" , lmStudioBaseUrl )
1667- await this . updateGlobalState ( "anthropicBaseUrl" , anthropicBaseUrl )
1668- await this . storeSecret ( "geminiApiKey" , geminiApiKey )
1669- await this . storeSecret ( "openAiNativeApiKey" , openAiNativeApiKey )
1670- await this . storeSecret ( "deepSeekApiKey" , deepSeekApiKey )
1671- await this . updateGlobalState ( "azureApiVersion" , azureApiVersion )
1672- await this . updateGlobalState ( "openAiStreamingEnabled" , openAiStreamingEnabled )
1673- await this . updateGlobalState ( "openRouterModelId" , openRouterModelId )
1674- await this . updateGlobalState ( "openRouterModelInfo" , openRouterModelInfo )
1675- await this . updateGlobalState ( "openRouterBaseUrl" , openRouterBaseUrl )
1676- await this . updateGlobalState ( "openRouterUseMiddleOutTransform" , openRouterUseMiddleOutTransform )
1677- await this . updateGlobalState ( "vsCodeLmModelSelector" , vsCodeLmModelSelector )
1678- await this . storeSecret ( "mistralApiKey" , mistralApiKey )
1679- await this . storeSecret ( "unboundApiKey" , unboundApiKey )
1680- await this . updateGlobalState ( "unboundModelId" , unboundModelId )
1681- await this . updateGlobalState ( "unboundModelInfo" , unboundModelInfo )
1682- await this . storeSecret ( "requestyApiKey" , requestyApiKey )
1683- await this . updateGlobalState ( "requestyModelId" , requestyModelId )
1684- await this . updateGlobalState ( "requestyModelInfo" , requestyModelInfo )
1685- await this . updateGlobalState ( "modelTemperature" , modelTemperature )
1656+ await Promise . all ( [
1657+ this . updateGlobalState ( "apiProvider" , apiProvider ) ,
1658+ this . updateGlobalState ( "apiModelId" , apiModelId ) ,
1659+ this . storeSecret ( "apiKey" , apiKey ) ,
1660+ this . updateGlobalState ( "glamaModelId" , glamaModelId ) ,
1661+ this . updateGlobalState ( "glamaModelInfo" , glamaModelInfo ) ,
1662+ this . storeSecret ( "glamaApiKey" , glamaApiKey ) ,
1663+ this . storeSecret ( "openRouterApiKey" , openRouterApiKey ) ,
1664+ this . storeSecret ( "awsAccessKey" , awsAccessKey ) ,
1665+ this . storeSecret ( "awsSecretKey" , awsSecretKey ) ,
1666+ this . storeSecret ( "awsSessionToken" , awsSessionToken ) ,
1667+ this . updateGlobalState ( "awsRegion" , awsRegion ) ,
1668+ this . updateGlobalState ( "awsUseCrossRegionInference" , awsUseCrossRegionInference ) ,
1669+ this . updateGlobalState ( "awsProfile" , awsProfile ) ,
1670+ this . updateGlobalState ( "awsUseProfile" , awsUseProfile ) ,
1671+ this . updateGlobalState ( "vertexProjectId" , vertexProjectId ) ,
1672+ this . updateGlobalState ( "vertexRegion" , vertexRegion ) ,
1673+ this . updateGlobalState ( "openAiBaseUrl" , openAiBaseUrl ) ,
1674+ this . storeSecret ( "openAiApiKey" , openAiApiKey ) ,
1675+ this . updateGlobalState ( "openAiModelId" , openAiModelId ) ,
1676+ this . updateGlobalState ( "openAiCustomModelInfo" , openAiCustomModelInfo ) ,
1677+ this . updateGlobalState ( "openAiUseAzure" , openAiUseAzure ) ,
1678+ this . updateGlobalState ( "ollamaModelId" , ollamaModelId ) ,
1679+ this . updateGlobalState ( "ollamaBaseUrl" , ollamaBaseUrl ) ,
1680+ this . updateGlobalState ( "lmStudioModelId" , lmStudioModelId ) ,
1681+ this . updateGlobalState ( "lmStudioBaseUrl" , lmStudioBaseUrl ) ,
1682+ this . updateGlobalState ( "anthropicBaseUrl" , anthropicBaseUrl ) ,
1683+ this . storeSecret ( "geminiApiKey" , geminiApiKey ) ,
1684+ this . storeSecret ( "openAiNativeApiKey" , openAiNativeApiKey ) ,
1685+ this . storeSecret ( "deepSeekApiKey" , deepSeekApiKey ) ,
1686+ this . updateGlobalState ( "azureApiVersion" , azureApiVersion ) ,
1687+ this . updateGlobalState ( "openAiStreamingEnabled" , openAiStreamingEnabled ) ,
1688+ this . updateGlobalState ( "openRouterModelId" , openRouterModelId ) ,
1689+ this . updateGlobalState ( "openRouterModelInfo" , openRouterModelInfo ) ,
1690+ this . updateGlobalState ( "openRouterBaseUrl" , openRouterBaseUrl ) ,
1691+ this . updateGlobalState ( "openRouterUseMiddleOutTransform" , openRouterUseMiddleOutTransform ) ,
1692+ this . updateGlobalState ( "vsCodeLmModelSelector" , vsCodeLmModelSelector ) ,
1693+ this . storeSecret ( "mistralApiKey" , mistralApiKey ) ,
1694+ this . storeSecret ( "unboundApiKey" , unboundApiKey ) ,
1695+ this . updateGlobalState ( "unboundModelId" , unboundModelId ) ,
1696+ this . updateGlobalState ( "unboundModelInfo" , unboundModelInfo ) ,
1697+ this . storeSecret ( "requestyApiKey" , requestyApiKey ) ,
1698+ this . updateGlobalState ( "requestyModelId" , requestyModelId ) ,
1699+ this . updateGlobalState ( "requestyModelInfo" , requestyModelInfo ) ,
1700+ this . updateGlobalState ( "modelTemperature" , modelTemperature ) ,
1701+ ] )
16861702 if ( this . cline ) {
16871703 this . cline . api = buildApiHandler ( apiConfiguration )
16881704 }
0 commit comments