@@ -1317,6 +1317,20 @@ export class ClineProvider implements vscode.WebviewViewProvider {
13171317 }
13181318 break
13191319 }
1320+ case "saveApiConfiguration" :
1321+ if ( message . text && message . apiConfiguration ) {
1322+ try {
1323+ await this . configManager . saveConfig ( message . text , message . apiConfiguration )
1324+ const listApiConfig = await this . configManager . listConfig ( )
1325+ await this . updateGlobalState ( "listApiConfigMeta" , listApiConfig )
1326+ } catch ( error ) {
1327+ this . outputChannel . appendLine (
1328+ `Error save api configuration: ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
1329+ )
1330+ vscode . window . showErrorMessage ( "Failed to save api configuration" )
1331+ }
1332+ }
1333+ break
13201334 case "upsertApiConfiguration" :
13211335 if ( message . text && message . apiConfiguration ) {
13221336 try {
@@ -1361,9 +1375,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
13611375 await this . postStateToWebview ( )
13621376 } catch ( error ) {
13631377 this . outputChannel . appendLine (
1364- `Error create new api configuration: ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
1378+ `Error rename api configuration: ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
13651379 )
1366- vscode . window . showErrorMessage ( "Failed to create api configuration" )
1380+ vscode . window . showErrorMessage ( "Failed to rename api configuration" )
13671381 }
13681382 }
13691383 break
@@ -1647,51 +1661,53 @@ export class ClineProvider implements vscode.WebviewViewProvider {
16471661 requestyModelInfo,
16481662 modelTemperature,
16491663 } = apiConfiguration
1650- await this . updateGlobalState ( "apiProvider" , apiProvider )
1651- await this . updateGlobalState ( "apiModelId" , apiModelId )
1652- await this . storeSecret ( "apiKey" , apiKey )
1653- await this . updateGlobalState ( "glamaModelId" , glamaModelId )
1654- await this . updateGlobalState ( "glamaModelInfo" , glamaModelInfo )
1655- await this . storeSecret ( "glamaApiKey" , glamaApiKey )
1656- await this . storeSecret ( "openRouterApiKey" , openRouterApiKey )
1657- await this . storeSecret ( "awsAccessKey" , awsAccessKey )
1658- await this . storeSecret ( "awsSecretKey" , awsSecretKey )
1659- await this . storeSecret ( "awsSessionToken" , awsSessionToken )
1660- await this . updateGlobalState ( "awsRegion" , awsRegion )
1661- await this . updateGlobalState ( "awsUseCrossRegionInference" , awsUseCrossRegionInference )
1662- await this . updateGlobalState ( "awsProfile" , awsProfile )
1663- await this . updateGlobalState ( "awsUseProfile" , awsUseProfile )
1664- await this . updateGlobalState ( "vertexProjectId" , vertexProjectId )
1665- await this . updateGlobalState ( "vertexRegion" , vertexRegion )
1666- await this . updateGlobalState ( "openAiBaseUrl" , openAiBaseUrl )
1667- await this . storeSecret ( "openAiApiKey" , openAiApiKey )
1668- await this . updateGlobalState ( "openAiModelId" , openAiModelId )
1669- await this . updateGlobalState ( "openAiCustomModelInfo" , openAiCustomModelInfo )
1670- await this . updateGlobalState ( "openAiUseAzure" , openAiUseAzure )
1671- await this . updateGlobalState ( "ollamaModelId" , ollamaModelId )
1672- await this . updateGlobalState ( "ollamaBaseUrl" , ollamaBaseUrl )
1673- await this . updateGlobalState ( "lmStudioModelId" , lmStudioModelId )
1674- await this . updateGlobalState ( "lmStudioBaseUrl" , lmStudioBaseUrl )
1675- await this . updateGlobalState ( "anthropicBaseUrl" , anthropicBaseUrl )
1676- await this . storeSecret ( "geminiApiKey" , geminiApiKey )
1677- await this . storeSecret ( "openAiNativeApiKey" , openAiNativeApiKey )
1678- await this . storeSecret ( "deepSeekApiKey" , deepSeekApiKey )
1679- await this . updateGlobalState ( "azureApiVersion" , azureApiVersion )
1680- await this . updateGlobalState ( "openAiStreamingEnabled" , openAiStreamingEnabled )
1681- await this . updateGlobalState ( "openRouterModelId" , openRouterModelId )
1682- await this . updateGlobalState ( "openRouterModelInfo" , openRouterModelInfo )
1683- await this . updateGlobalState ( "openRouterBaseUrl" , openRouterBaseUrl )
1684- await this . updateGlobalState ( "openRouterUseMiddleOutTransform" , openRouterUseMiddleOutTransform )
1685- await this . updateGlobalState ( "vsCodeLmModelSelector" , vsCodeLmModelSelector )
1686- await this . storeSecret ( "mistralApiKey" , mistralApiKey )
1687- await this . updateGlobalState ( "mistralCodestralUrl" , mistralCodestralUrl )
1688- await this . storeSecret ( "unboundApiKey" , unboundApiKey )
1689- await this . updateGlobalState ( "unboundModelId" , unboundModelId )
1690- await this . updateGlobalState ( "unboundModelInfo" , unboundModelInfo )
1691- await this . storeSecret ( "requestyApiKey" , requestyApiKey )
1692- await this . updateGlobalState ( "requestyModelId" , requestyModelId )
1693- await this . updateGlobalState ( "requestyModelInfo" , requestyModelInfo )
1694- await this . updateGlobalState ( "modelTemperature" , modelTemperature )
1664+ await Promise . all ( [
1665+ this . updateGlobalState ( "apiProvider" , apiProvider ) ,
1666+ this . updateGlobalState ( "apiModelId" , apiModelId ) ,
1667+ this . storeSecret ( "apiKey" , apiKey ) ,
1668+ this . updateGlobalState ( "glamaModelId" , glamaModelId ) ,
1669+ this . updateGlobalState ( "glamaModelInfo" , glamaModelInfo ) ,
1670+ this . storeSecret ( "glamaApiKey" , glamaApiKey ) ,
1671+ this . storeSecret ( "openRouterApiKey" , openRouterApiKey ) ,
1672+ this . storeSecret ( "awsAccessKey" , awsAccessKey ) ,
1673+ this . storeSecret ( "awsSecretKey" , awsSecretKey ) ,
1674+ this . storeSecret ( "awsSessionToken" , awsSessionToken ) ,
1675+ this . updateGlobalState ( "awsRegion" , awsRegion ) ,
1676+ this . updateGlobalState ( "awsUseCrossRegionInference" , awsUseCrossRegionInference ) ,
1677+ this . updateGlobalState ( "awsProfile" , awsProfile ) ,
1678+ this . updateGlobalState ( "awsUseProfile" , awsUseProfile ) ,
1679+ this . updateGlobalState ( "vertexProjectId" , vertexProjectId ) ,
1680+ this . updateGlobalState ( "vertexRegion" , vertexRegion ) ,
1681+ this . updateGlobalState ( "openAiBaseUrl" , openAiBaseUrl ) ,
1682+ this . storeSecret ( "openAiApiKey" , openAiApiKey ) ,
1683+ this . updateGlobalState ( "openAiModelId" , openAiModelId ) ,
1684+ this . updateGlobalState ( "openAiCustomModelInfo" , openAiCustomModelInfo ) ,
1685+ this . updateGlobalState ( "openAiUseAzure" , openAiUseAzure ) ,
1686+ this . updateGlobalState ( "ollamaModelId" , ollamaModelId ) ,
1687+ this . updateGlobalState ( "ollamaBaseUrl" , ollamaBaseUrl ) ,
1688+ this . updateGlobalState ( "lmStudioModelId" , lmStudioModelId ) ,
1689+ this . updateGlobalState ( "lmStudioBaseUrl" , lmStudioBaseUrl ) ,
1690+ this . updateGlobalState ( "anthropicBaseUrl" , anthropicBaseUrl ) ,
1691+ this . storeSecret ( "geminiApiKey" , geminiApiKey ) ,
1692+ this . storeSecret ( "openAiNativeApiKey" , openAiNativeApiKey ) ,
1693+ this . storeSecret ( "deepSeekApiKey" , deepSeekApiKey ) ,
1694+ this . updateGlobalState ( "azureApiVersion" , azureApiVersion ) ,
1695+ this . updateGlobalState ( "openAiStreamingEnabled" , openAiStreamingEnabled ) ,
1696+ this . updateGlobalState ( "openRouterModelId" , openRouterModelId ) ,
1697+ this . updateGlobalState ( "openRouterModelInfo" , openRouterModelInfo ) ,
1698+ this . updateGlobalState ( "openRouterBaseUrl" , openRouterBaseUrl ) ,
1699+ this . updateGlobalState ( "openRouterUseMiddleOutTransform" , openRouterUseMiddleOutTransform ) ,
1700+ this . updateGlobalState ( "vsCodeLmModelSelector" , vsCodeLmModelSelector ) ,
1701+ this . storeSecret ( "mistralApiKey" , mistralApiKey ) ,
1702+ this . updateGlobalState ( "mistralCodestralUrl" , mistralCodestralUrl ) ,
1703+ this . storeSecret ( "unboundApiKey" , unboundApiKey ) ,
1704+ this . updateGlobalState ( "unboundModelId" , unboundModelId ) ,
1705+ this . updateGlobalState ( "unboundModelInfo" , unboundModelInfo ) ,
1706+ this . storeSecret ( "requestyApiKey" , requestyApiKey ) ,
1707+ this . updateGlobalState ( "requestyModelId" , requestyModelId ) ,
1708+ this . updateGlobalState ( "requestyModelInfo" , requestyModelInfo ) ,
1709+ this . updateGlobalState ( "modelTemperature" , modelTemperature ) ,
1710+ ] )
16951711 if ( this . cline ) {
16961712 this . cline . api = buildApiHandler ( apiConfiguration )
16971713 }
0 commit comments