@@ -14,7 +14,7 @@ import { getTheme } from "../../integrations/theme/getTheme"
1414import { getDiffStrategy } from "../diff/DiffStrategy"
1515import WorkspaceTracker from "../../integrations/workspace/WorkspaceTracker"
1616import { McpHub } from "../../services/mcp/McpHub"
17- import { ApiConfiguration , ApiProvider , ModelInfo } from "../../shared/api"
17+ import { ApiConfiguration , ApiProvider , ModelInfo , PEARAI_URL } from "../../shared/api"
1818import { findLast } from "../../shared/array"
1919import { ApiConfigMeta , ExtensionMessage } from "../../shared/ExtensionMessage"
2020import { HistoryItem } from "../../shared/HistoryItem"
@@ -63,6 +63,8 @@ type SecretKey =
6363 | "openAiNativeApiKey"
6464 | "deepSeekApiKey"
6565 | "mistralApiKey"
66+ | "pearai-token"
67+ | "pearai-refresh" // Array of custom modes
6668 | "unboundApiKey"
6769type GlobalStateKey =
6870 | "apiProvider"
@@ -98,6 +100,10 @@ type GlobalStateKey =
98100 | "openRouterModelId"
99101 | "openRouterModelInfo"
100102 | "openRouterBaseUrl"
103+ | "pearaiModelId"
104+ | "pearaiModelInfo"
105+ | "pearaiBaseUrl"
106+ | "pearaiApiKey"
101107 | "openRouterUseMiddleOutTransform"
102108 | "allowedCommands"
103109 | "soundEnabled"
@@ -1373,6 +1379,19 @@ export class ClineProvider implements vscode.WebviewViewProvider {
13731379 await this . updateGlobalState ( "mode" , defaultModeSlug )
13741380 await this . postStateToWebview ( )
13751381 }
1382+ break
1383+ case "openPearAiAuth" :
1384+ const extensionUrl = `${ vscode . env . uriScheme } ://pearai.pearai/auth`
1385+ const callbackUri = await vscode . env . asExternalUri ( vscode . Uri . parse ( extensionUrl ) )
1386+
1387+ await vscode . env . openExternal (
1388+ await vscode . env . asExternalUri (
1389+ vscode . Uri . parse (
1390+ `https://trypear.ai/signin?callback=${ callbackUri . toString ( ) } ` , // Change to localhost if running locally
1391+ ) ,
1392+ ) ,
1393+ )
1394+ break
13761395 }
13771396 } ,
13781397 null ,
@@ -1422,7 +1441,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
14221441 // Update mode's default config
14231442 const { mode } = await this . getState ( )
14241443 if ( mode ) {
1425- const currentApiConfigName = await this . getGlobalState ( "currentApiConfigName" )
1444+ const currentApiConfigName = ( await this . getGlobalState ( "currentApiConfigName" ) ) ?? "default"
14261445 const listApiConfig = await this . configManager . listConfig ( )
14271446 const config = listApiConfig ?. find ( ( c ) => c . name === currentApiConfigName )
14281447 if ( config ?. id ) {
@@ -1468,6 +1487,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
14681487 openRouterUseMiddleOutTransform,
14691488 vsCodeLmModelSelector,
14701489 mistralApiKey,
1490+ pearaiBaseUrl,
1491+ pearaiModelId,
1492+ pearaiModelInfo,
14711493 unboundApiKey,
14721494 unboundModelId,
14731495 } = apiConfiguration
@@ -1508,6 +1530,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
15081530 await this . updateGlobalState ( "openRouterUseMiddleOutTransform" , openRouterUseMiddleOutTransform )
15091531 await this . updateGlobalState ( "vsCodeLmModelSelector" , vsCodeLmModelSelector )
15101532 await this . storeSecret ( "mistralApiKey" , mistralApiKey )
1533+ await this . updateGlobalState ( "pearaiBaseUrl" , PEARAI_URL )
1534+ await this . updateGlobalState ( "pearaiModelId" , pearaiModelId )
1535+ await this . updateGlobalState ( "pearaiModelInfo" , pearaiModelInfo )
15111536 await this . storeSecret ( "unboundApiKey" , unboundApiKey )
15121537 await this . updateGlobalState ( "unboundModelId" , unboundModelId )
15131538 if ( this . cline ) {
@@ -2140,6 +2165,11 @@ export class ClineProvider implements vscode.WebviewViewProvider {
21402165 openAiNativeApiKey ,
21412166 deepSeekApiKey ,
21422167 mistralApiKey ,
2168+ pearaiApiKey ,
2169+ pearaiRefreshKey ,
2170+ pearaiBaseUrl ,
2171+ pearaiModelId ,
2172+ pearaiModelInfo ,
21432173 azureApiVersion ,
21442174 openAiStreamingEnabled ,
21452175 openRouterModelId ,
@@ -2213,6 +2243,11 @@ export class ClineProvider implements vscode.WebviewViewProvider {
22132243 this . getSecret ( "openAiNativeApiKey" ) as Promise < string | undefined > ,
22142244 this . getSecret ( "deepSeekApiKey" ) as Promise < string | undefined > ,
22152245 this . getSecret ( "mistralApiKey" ) as Promise < string | undefined > ,
2246+ this . getSecret ( "pearai-token" ) as Promise < string | undefined > ,
2247+ this . getSecret ( "pearai-refresh" ) as Promise < string | undefined > ,
2248+ this . getGlobalState ( "pearaiBaseUrl" ) as Promise < string | undefined > ,
2249+ this . getGlobalState ( "pearaiModelId" ) as Promise < string | undefined > ,
2250+ this . getGlobalState ( "pearaiModelInfo" ) as Promise < ModelInfo | undefined > ,
22162251 this . getGlobalState ( "azureApiVersion" ) as Promise < string | undefined > ,
22172252 this . getGlobalState ( "openAiStreamingEnabled" ) as Promise < boolean | undefined > ,
22182253 this . getGlobalState ( "openRouterModelId" ) as Promise < string | undefined > ,
@@ -2303,6 +2338,10 @@ export class ClineProvider implements vscode.WebviewViewProvider {
23032338 openAiNativeApiKey,
23042339 deepSeekApiKey,
23052340 mistralApiKey,
2341+ pearaiApiKey,
2342+ pearaiBaseUrl,
2343+ pearaiModelId,
2344+ pearaiModelInfo,
23062345 azureApiVersion,
23072346 openAiStreamingEnabled,
23082347 openRouterModelId,
0 commit comments