|
@@ -1,7 +1,7 @@
|
|
|
import { Anthropic } from "@anthropic-ai/sdk"
|
|
import { Anthropic } from "@anthropic-ai/sdk"
|
|
|
import * as vscode from "vscode"
|
|
import * as vscode from "vscode"
|
|
|
import { ClaudeDev } from "../ClaudeDev"
|
|
import { ClaudeDev } from "../ClaudeDev"
|
|
|
-import { ApiModelId, ApiProvider } from "../shared/api"
|
|
|
|
|
|
|
+import { ApiProvider } from "../shared/api"
|
|
|
import { ExtensionMessage } from "../shared/ExtensionMessage"
|
|
import { ExtensionMessage } from "../shared/ExtensionMessage"
|
|
|
import { WebviewMessage } from "../shared/WebviewMessage"
|
|
import { WebviewMessage } from "../shared/WebviewMessage"
|
|
|
import { downloadTask, findLast, getNonce, getUri, selectImages } from "../utils"
|
|
import { downloadTask, findLast, getNonce, getUri, selectImages } from "../utils"
|
|
@@ -16,7 +16,7 @@ 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
|
|
https://github.com/KumarVariable/vscode-extension-sidebar-html/blob/master/src/customSidebarViewProvider.ts
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
-type SecretKey = "apiKey" | "openRouterApiKey" | "awsAccessKey" | "awsSecretKey" | "awsSessionToken"
|
|
|
|
|
|
|
+type SecretKey = "apiKey" | "openRouterApiKey" | "awsAccessKey" | "awsSecretKey" | "awsSessionToken" | "openAiApiKey"
|
|
|
type GlobalStateKey =
|
|
type GlobalStateKey =
|
|
|
| "apiProvider"
|
|
| "apiProvider"
|
|
|
| "apiModelId"
|
|
| "apiModelId"
|
|
@@ -27,6 +27,8 @@ type GlobalStateKey =
|
|
|
| "customInstructions"
|
|
| "customInstructions"
|
|
|
| "alwaysAllowReadOnly"
|
|
| "alwaysAllowReadOnly"
|
|
|
| "taskHistory"
|
|
| "taskHistory"
|
|
|
|
|
+ | "openAiBaseUrl"
|
|
|
|
|
+ | "openAiModelId"
|
|
|
|
|
|
|
|
export class ClaudeDevProvider implements vscode.WebviewViewProvider {
|
|
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.
|
|
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.
|
|
@@ -314,6 +316,9 @@ export class ClaudeDevProvider implements vscode.WebviewViewProvider {
|
|
|
awsRegion,
|
|
awsRegion,
|
|
|
vertexProjectId,
|
|
vertexProjectId,
|
|
|
vertexRegion,
|
|
vertexRegion,
|
|
|
|
|
+ openAiBaseUrl,
|
|
|
|
|
+ openAiApiKey,
|
|
|
|
|
+ openAiModelId,
|
|
|
} = message.apiConfiguration
|
|
} = message.apiConfiguration
|
|
|
await this.updateGlobalState("apiProvider", apiProvider)
|
|
await this.updateGlobalState("apiProvider", apiProvider)
|
|
|
await this.updateGlobalState("apiModelId", apiModelId)
|
|
await this.updateGlobalState("apiModelId", apiModelId)
|
|
@@ -325,6 +330,9 @@ export class ClaudeDevProvider implements vscode.WebviewViewProvider {
|
|
|
await this.updateGlobalState("awsRegion", awsRegion)
|
|
await this.updateGlobalState("awsRegion", awsRegion)
|
|
|
await this.updateGlobalState("vertexProjectId", vertexProjectId)
|
|
await this.updateGlobalState("vertexProjectId", vertexProjectId)
|
|
|
await this.updateGlobalState("vertexRegion", vertexRegion)
|
|
await this.updateGlobalState("vertexRegion", vertexRegion)
|
|
|
|
|
+ await this.updateGlobalState("openAiBaseUrl", openAiBaseUrl)
|
|
|
|
|
+ await this.storeSecret("openAiApiKey", openAiApiKey)
|
|
|
|
|
+ await this.updateGlobalState("openAiModelId", openAiModelId)
|
|
|
this.claudeDev?.updateApi(message.apiConfiguration)
|
|
this.claudeDev?.updateApi(message.apiConfiguration)
|
|
|
}
|
|
}
|
|
|
await this.postStateToWebview()
|
|
await this.postStateToWebview()
|
|
@@ -615,13 +623,16 @@ export class ClaudeDevProvider implements vscode.WebviewViewProvider {
|
|
|
awsRegion,
|
|
awsRegion,
|
|
|
vertexProjectId,
|
|
vertexProjectId,
|
|
|
vertexRegion,
|
|
vertexRegion,
|
|
|
|
|
+ openAiBaseUrl,
|
|
|
|
|
+ openAiApiKey,
|
|
|
|
|
+ openAiModelId,
|
|
|
lastShownAnnouncementId,
|
|
lastShownAnnouncementId,
|
|
|
customInstructions,
|
|
customInstructions,
|
|
|
alwaysAllowReadOnly,
|
|
alwaysAllowReadOnly,
|
|
|
taskHistory,
|
|
taskHistory,
|
|
|
] = await Promise.all([
|
|
] = await Promise.all([
|
|
|
this.getGlobalState("apiProvider") as Promise<ApiProvider | undefined>,
|
|
this.getGlobalState("apiProvider") as Promise<ApiProvider | undefined>,
|
|
|
- this.getGlobalState("apiModelId") as Promise<ApiModelId | undefined>,
|
|
|
|
|
|
|
+ this.getGlobalState("apiModelId") as Promise<string | undefined>,
|
|
|
this.getSecret("apiKey") as Promise<string | undefined>,
|
|
this.getSecret("apiKey") as Promise<string | undefined>,
|
|
|
this.getSecret("openRouterApiKey") as Promise<string | undefined>,
|
|
this.getSecret("openRouterApiKey") as Promise<string | undefined>,
|
|
|
this.getSecret("awsAccessKey") as Promise<string | undefined>,
|
|
this.getSecret("awsAccessKey") as Promise<string | undefined>,
|
|
@@ -630,6 +641,9 @@ export class ClaudeDevProvider implements vscode.WebviewViewProvider {
|
|
|
this.getGlobalState("awsRegion") as Promise<string | undefined>,
|
|
this.getGlobalState("awsRegion") as Promise<string | undefined>,
|
|
|
this.getGlobalState("vertexProjectId") as Promise<string | undefined>,
|
|
this.getGlobalState("vertexProjectId") as Promise<string | undefined>,
|
|
|
this.getGlobalState("vertexRegion") as Promise<string | undefined>,
|
|
this.getGlobalState("vertexRegion") as Promise<string | undefined>,
|
|
|
|
|
+ this.getGlobalState("openAiBaseUrl") as Promise<string | undefined>,
|
|
|
|
|
+ this.getSecret("openAiApiKey") as Promise<string | undefined>,
|
|
|
|
|
+ this.getGlobalState("openAiModelId") as Promise<string | undefined>,
|
|
|
this.getGlobalState("lastShownAnnouncementId") as Promise<string | undefined>,
|
|
this.getGlobalState("lastShownAnnouncementId") as Promise<string | undefined>,
|
|
|
this.getGlobalState("customInstructions") as Promise<string | undefined>,
|
|
this.getGlobalState("customInstructions") as Promise<string | undefined>,
|
|
|
this.getGlobalState("alwaysAllowReadOnly") as Promise<boolean | undefined>,
|
|
this.getGlobalState("alwaysAllowReadOnly") as Promise<boolean | undefined>,
|
|
@@ -662,6 +676,9 @@ export class ClaudeDevProvider implements vscode.WebviewViewProvider {
|
|
|
awsRegion,
|
|
awsRegion,
|
|
|
vertexProjectId,
|
|
vertexProjectId,
|
|
|
vertexRegion,
|
|
vertexRegion,
|
|
|
|
|
+ openAiBaseUrl,
|
|
|
|
|
+ openAiApiKey,
|
|
|
|
|
+ openAiModelId,
|
|
|
},
|
|
},
|
|
|
lastShownAnnouncementId,
|
|
lastShownAnnouncementId,
|
|
|
customInstructions,
|
|
customInstructions,
|
|
@@ -739,6 +756,7 @@ export class ClaudeDevProvider implements vscode.WebviewViewProvider {
|
|
|
"awsAccessKey",
|
|
"awsAccessKey",
|
|
|
"awsSecretKey",
|
|
"awsSecretKey",
|
|
|
"awsSessionToken",
|
|
"awsSessionToken",
|
|
|
|
|
+ "openAiApiKey",
|
|
|
]
|
|
]
|
|
|
for (const key of secretKeys) {
|
|
for (const key of secretKeys) {
|
|
|
await this.storeSecret(key, undefined)
|
|
await this.storeSecret(key, undefined)
|