mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-21 12:51:17 -05:00
Remove Kodu provider
This commit is contained in:
@@ -8,7 +8,6 @@ import { downloadTask, getNonce, getUri, selectImages } from "../utils"
|
||||
import * as path from "path"
|
||||
import fs from "fs/promises"
|
||||
import { HistoryItem } from "../shared/HistoryItem"
|
||||
import { fetchKoduCredits } from "../api/kodu"
|
||||
|
||||
/*
|
||||
https://github.com/microsoft/vscode-webview-ui-toolkit-samples/blob/main/default/weather-webview/src/providers/WeatherViewProvider.ts
|
||||
@@ -16,19 +15,16 @@ https://github.com/microsoft/vscode-webview-ui-toolkit-samples/blob/main/default
|
||||
https://github.com/KumarVariable/vscode-extension-sidebar-html/blob/master/src/customSidebarViewProvider.ts
|
||||
*/
|
||||
|
||||
type SecretKey = "apiKey" | "openRouterApiKey" | "awsAccessKey" | "awsSecretKey" | "koduApiKey"
|
||||
type SecretKey = "apiKey" | "openRouterApiKey" | "awsAccessKey" | "awsSecretKey"
|
||||
type GlobalStateKey =
|
||||
| "apiProvider"
|
||||
| "apiModelId"
|
||||
| "awsRegion"
|
||||
| "koduEmail"
|
||||
| "koduCredits"
|
||||
| "maxRequestsPerTask"
|
||||
| "lastShownAnnouncementId"
|
||||
| "customInstructions"
|
||||
| "alwaysAllowReadOnly"
|
||||
| "taskHistory"
|
||||
| "shouldShowKoduPromo"
|
||||
|
||||
export class ClaudeDevProvider implements vscode.WebviewViewProvider {
|
||||
public static readonly sideBarId = "claude-dev.SidebarProvider" // used in package.json as the view's id. This value cannot be changed due to how vscode caches views based on their id, and updating the id would break existing instances of the extension.
|
||||
@@ -40,6 +36,28 @@ export class ClaudeDevProvider implements vscode.WebviewViewProvider {
|
||||
|
||||
constructor(readonly context: vscode.ExtensionContext, private readonly outputChannel: vscode.OutputChannel) {
|
||||
this.outputChannel.appendLine("ClaudeDevProvider instantiated")
|
||||
this.revertKodu()
|
||||
}
|
||||
|
||||
async revertKodu() {
|
||||
const apiProvider = await this.getGlobalState("apiProvider")
|
||||
if (apiProvider === "kodu") {
|
||||
// switch back to previous provider
|
||||
const anthropicKey = await this.getSecret("apiKey")
|
||||
if (anthropicKey) {
|
||||
await this.updateGlobalState("apiProvider", "anthropic" as ApiProvider)
|
||||
} else {
|
||||
const openRouterApiKey = await this.getSecret("openRouterApiKey")
|
||||
if (openRouterApiKey) {
|
||||
await this.updateGlobalState("apiProvider", "openrouter" as ApiProvider)
|
||||
} else {
|
||||
const awsAccessKey = await this.getSecret("awsAccessKey")
|
||||
if (awsAccessKey) {
|
||||
await this.updateGlobalState("apiProvider", "bedrock" as ApiProvider)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -359,25 +377,6 @@ export class ClaudeDevProvider implements vscode.WebviewViewProvider {
|
||||
case "exportTaskWithId":
|
||||
this.exportTaskWithId(message.text!)
|
||||
break
|
||||
case "didClickKoduSignOut":
|
||||
await this.signOutKodu()
|
||||
break
|
||||
case "fetchKoduCredits":
|
||||
const koduApiKey = await this.getSecret("koduApiKey")
|
||||
if (koduApiKey) {
|
||||
const credits = await fetchKoduCredits({ apiKey: koduApiKey })
|
||||
await this.updateGlobalState("koduCredits", credits)
|
||||
await this.postMessageToWebview({
|
||||
type: "action",
|
||||
action: "koduCreditsFetched",
|
||||
state: await this.getStateToPostToWebview(),
|
||||
})
|
||||
}
|
||||
break
|
||||
case "didDismissKoduPromo":
|
||||
await this.updateGlobalState("shouldShowKoduPromo", false)
|
||||
await this.postStateToWebview()
|
||||
break
|
||||
case "resetState":
|
||||
await this.resetState()
|
||||
break
|
||||
@@ -390,27 +389,6 @@ export class ClaudeDevProvider implements vscode.WebviewViewProvider {
|
||||
)
|
||||
}
|
||||
|
||||
// Kodu
|
||||
|
||||
async saveKoduApiKey(apiKey: string, email?: string) {
|
||||
await this.storeSecret("koduApiKey", apiKey)
|
||||
await this.updateGlobalState("koduEmail", email)
|
||||
await this.updateGlobalState("apiProvider", "kodu")
|
||||
await this.updateGlobalState("shouldShowKoduPromo", false)
|
||||
await this.postStateToWebview()
|
||||
await this.postMessageToWebview({ type: "action", action: "koduAuthenticated" })
|
||||
this.claudeDev?.updateApi({ apiProvider: "kodu", koduApiKey: apiKey })
|
||||
}
|
||||
|
||||
async signOutKodu() {
|
||||
await this.storeSecret("koduApiKey", undefined)
|
||||
await this.updateGlobalState("koduEmail", undefined)
|
||||
await this.updateGlobalState("koduCredits", undefined)
|
||||
await this.updateGlobalState("apiProvider", "kodu")
|
||||
this.claudeDev?.updateApi({ apiProvider: "kodu", koduApiKey: undefined })
|
||||
await this.postStateToWebview()
|
||||
}
|
||||
|
||||
// Task history
|
||||
|
||||
async getTaskWithId(id: string): Promise<{
|
||||
@@ -510,8 +488,6 @@ export class ClaudeDevProvider implements vscode.WebviewViewProvider {
|
||||
customInstructions,
|
||||
alwaysAllowReadOnly,
|
||||
taskHistory,
|
||||
koduCredits,
|
||||
shouldShowKoduPromo,
|
||||
} = await this.getState()
|
||||
return {
|
||||
version: this.context.extension?.packageJSON?.version ?? "",
|
||||
@@ -524,8 +500,6 @@ export class ClaudeDevProvider implements vscode.WebviewViewProvider {
|
||||
claudeMessages: this.claudeDev?.claudeMessages || [],
|
||||
taskHistory: (taskHistory || []).filter((item) => item.ts && item.task).sort((a, b) => b.ts - a.ts),
|
||||
shouldShowAnnouncement: lastShownAnnouncementId !== this.latestAnnouncementId,
|
||||
koduCredits,
|
||||
shouldShowKoduPromo,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -624,15 +598,11 @@ export class ClaudeDevProvider implements vscode.WebviewViewProvider {
|
||||
awsAccessKey,
|
||||
awsSecretKey,
|
||||
awsRegion,
|
||||
koduApiKey,
|
||||
koduEmail,
|
||||
koduCredits,
|
||||
maxRequestsPerTask,
|
||||
lastShownAnnouncementId,
|
||||
customInstructions,
|
||||
alwaysAllowReadOnly,
|
||||
taskHistory,
|
||||
shouldShowKoduPromo,
|
||||
] = await Promise.all([
|
||||
this.getGlobalState("apiProvider") as Promise<ApiProvider | undefined>,
|
||||
this.getGlobalState("apiModelId") as Promise<ApiModelId | undefined>,
|
||||
@@ -641,15 +611,11 @@ export class ClaudeDevProvider implements vscode.WebviewViewProvider {
|
||||
this.getSecret("awsAccessKey") as Promise<string | undefined>,
|
||||
this.getSecret("awsSecretKey") as Promise<string | undefined>,
|
||||
this.getGlobalState("awsRegion") as Promise<string | undefined>,
|
||||
this.getSecret("koduApiKey") as Promise<string | undefined>,
|
||||
this.getGlobalState("koduEmail") as Promise<string | undefined>,
|
||||
this.getGlobalState("koduCredits") as Promise<number | undefined>,
|
||||
this.getGlobalState("maxRequestsPerTask") as Promise<number | undefined>,
|
||||
this.getGlobalState("lastShownAnnouncementId") as Promise<string | undefined>,
|
||||
this.getGlobalState("customInstructions") as Promise<string | undefined>,
|
||||
this.getGlobalState("alwaysAllowReadOnly") as Promise<boolean | undefined>,
|
||||
this.getGlobalState("taskHistory") as Promise<HistoryItem[] | undefined>,
|
||||
this.getGlobalState("shouldShowKoduPromo") as Promise<boolean | undefined>,
|
||||
])
|
||||
|
||||
let apiProvider: ApiProvider
|
||||
@@ -661,8 +627,8 @@ export class ClaudeDevProvider implements vscode.WebviewViewProvider {
|
||||
if (apiKey) {
|
||||
apiProvider = "anthropic"
|
||||
} else {
|
||||
// New users should default to kodu
|
||||
apiProvider = "kodu"
|
||||
// New users should default to anthropic
|
||||
apiProvider = "anthropic"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -675,16 +641,12 @@ export class ClaudeDevProvider implements vscode.WebviewViewProvider {
|
||||
awsAccessKey,
|
||||
awsSecretKey,
|
||||
awsRegion,
|
||||
koduApiKey,
|
||||
koduEmail,
|
||||
},
|
||||
maxRequestsPerTask,
|
||||
lastShownAnnouncementId,
|
||||
customInstructions,
|
||||
alwaysAllowReadOnly: alwaysAllowReadOnly ?? false,
|
||||
taskHistory,
|
||||
koduCredits,
|
||||
shouldShowKoduPromo: shouldShowKoduPromo ?? true,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -700,10 +662,6 @@ export class ClaudeDevProvider implements vscode.WebviewViewProvider {
|
||||
return history
|
||||
}
|
||||
|
||||
async updateKoduCredits(credits: number) {
|
||||
await this.updateGlobalState("koduCredits", credits)
|
||||
}
|
||||
|
||||
// global
|
||||
|
||||
private async updateGlobalState(key: GlobalStateKey, value: any) {
|
||||
@@ -755,7 +713,7 @@ export class ClaudeDevProvider implements vscode.WebviewViewProvider {
|
||||
for (const key of this.context.globalState.keys()) {
|
||||
await this.context.globalState.update(key, undefined)
|
||||
}
|
||||
const secretKeys: SecretKey[] = ["apiKey", "openRouterApiKey", "awsAccessKey", "awsSecretKey", "koduApiKey"]
|
||||
const secretKeys: SecretKey[] = ["apiKey", "openRouterApiKey", "awsAccessKey", "awsSecretKey"]
|
||||
for (const key of secretKeys) {
|
||||
await this.storeSecret(key, undefined)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user