adding cline apikey to context

This commit is contained in:
pashpashpash
2025-01-28 10:58:01 -08:00
parent cf61a8961a
commit 6e65b869ae
4 changed files with 15 additions and 4 deletions
+7 -1
View File
@@ -37,6 +37,7 @@ https://github.com/KumarVariable/vscode-extension-sidebar-html/blob/master/src/c
type SecretKey =
| "apiKey"
| "clineApiKey"
| "openRouterApiKey"
| "awsAccessKey"
| "awsSecretKey"
@@ -836,13 +837,18 @@ export class ClineProvider implements vscode.WebviewViewProvider {
return true
}
async handleAuthCallback(token: string) {
async handleAuthCallback(token: string, apiKey: string) {
try {
// First sign in with Firebase to trigger auth state change
await this.authManager.signInWithCustomToken(token)
// Then store the token securely
await this.storeSecret("authToken", token)
await this.storeSecret("clineApiKey", apiKey)
const clineProvider: ApiProvider = "cline"
await this.updateGlobalState("apiProvider", clineProvider)
await this.postStateToWebview()
vscode.window.showInformationMessage("Successfully logged in to Cline")
} catch (error) {
+4 -2
View File
@@ -158,10 +158,12 @@ export function activate(context: vscode.ExtensionContext) {
case "/auth": {
const token = query.get("token")
const state = query.get("state")
const apiKey = query.get("apiKey")
console.log("Auth callback received:", {
token: token,
state: state,
apiKey: apiKey,
})
// Validate state parameter
@@ -170,8 +172,8 @@ export function activate(context: vscode.ExtensionContext) {
return
}
if (token) {
await visibleProvider.handleAuthCallback(token)
if (token && apiKey) {
await visibleProvider.handleAuthCallback(token, apiKey)
}
break
}
+2
View File
@@ -11,10 +11,12 @@ export type ApiProvider =
| "deepseek"
| "mistral"
| "vscode-lm"
| "cline"
export interface ApiHandlerOptions {
apiModelId?: string
apiKey?: string // anthropic
clineApiKey?: string
anthropicBaseUrl?: string
openRouterApiKey?: string
openRouterModelId?: string
@@ -70,9 +70,10 @@ export const ExtensionStateContextProvider: React.FC<{
config.deepSeekApiKey,
config.mistralApiKey,
config.vsCodeLmModelSelector,
config.clineApiKey,
].some((key) => key !== undefined)
: false
setShowWelcome(!hasKey && !message.state!.isLoggedIn)
setShowWelcome(!hasKey)
setDidHydrateState(true)
break
}