mirror of
https://github.com/cline/cline.git
synced 2026-09-16 21:01:52 +08:00
adding cline apikey to context
This commit is contained in:
@@ -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
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user