Skip to content

Commit c4d4760

Browse files
committed
Progress
1 parent e3f4d52 commit c4d4760

6 files changed

Lines changed: 14 additions & 18 deletions

File tree

src/api/providers/pearai.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { ApiHandlerOptions, PEARAI_URL, ModelInfo } from "../../shared/api"
33
import { AnthropicHandler } from "./anthropic"
44
import { DeepSeekHandler } from "./deepseek"
55
import Anthropic from "@anthropic-ai/sdk"
6+
import { BaseProvider } from "./base-provider"
7+
import { SingleCompletionHandler } from "../"
68

79
interface PearAiModelsResponse {
810
models: {
@@ -14,10 +16,11 @@ interface PearAiModelsResponse {
1416
defaultModelId: string
1517
}
1618

17-
export class PearAiHandler {
19+
export class PearAiHandler extends BaseProvider implements SingleCompletionHandler {
1820
private handler!: AnthropicHandler | DeepSeekHandler
1921

2022
constructor(options: ApiHandlerOptions) {
23+
super()
2124
if (!options.pearaiApiKey) {
2225
vscode.window.showErrorMessage("PearAI API key not found.", "Login to PearAI").then(async (selection) => {
2326
if (selection === "Login to PearAI") {
@@ -151,8 +154,4 @@ export class PearAiHandler {
151154
async completePrompt(prompt: string): Promise<string> {
152155
return this.handler.completePrompt(prompt)
153156
}
154-
155-
async countTokens(content: Array<Anthropic.Messages.ContentBlockParam>): Promise<number> {
156-
return this.handler.countTokens(content)
157-
}
158157
}

src/exports/roo-code.d.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ export type SecretKey =
162162
| "mistralApiKey"
163163
| "unboundApiKey"
164164
| "requestyApiKey"
165-
| "pearaiToken"
166-
| "pearaiRefresh"
165+
| "pearaiApiKey"
166+
167167
export type GlobalStateKey =
168168
| "apiProvider"
169169
| "apiModelId"
@@ -256,7 +256,6 @@ export type GlobalStateKey =
256256
| "language"
257257
| "maxReadFileLine"
258258
| "fakeAi"
259-
| "pearaiApiKey"
260259
| "pearaiModelId"
261260
| "pearaiModelInfo"
262261
| "pearaiBaseUrl"

src/extension.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ export function activate(context: vscode.ExtensionContext) {
9393
vscode.commands.registerCommand("pearai-roo-cline.pearaiLogin", async (data) => {
9494
console.dir("Logged in to PearAI:")
9595
console.dir(data)
96-
context.secrets.store("pearai-token", data.accessToken)
97-
context.secrets.store("pearai-refresh", data.refreshToken)
96+
context.secrets.store("pearaiApiKey", data.accessToken)
97+
context.secrets.store("pearaiRefreshKey", data.refreshToken)
9898
// Update MCP server with new token
9999
// const provider = await ClineProvider.getInstance()
100100
// if (provider) {
@@ -110,8 +110,8 @@ export function activate(context: vscode.ExtensionContext) {
110110
context.subscriptions.push(
111111
vscode.commands.registerCommand("pearai-roo-cline.pearaiLogout", async () => {
112112
console.dir("Logged out of PearAI:")
113-
context.secrets.delete("pearai-token")
114-
context.secrets.delete("pearai-refresh")
113+
context.secrets.delete("pearaiApiKey")
114+
context.secrets.delete("pearaiRefreshKey")
115115
// Clear MCP server token
116116
const provider = await ClineProvider.getInstance()
117117
// if (provider) {

src/shared/checkExistApiConfig.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { SECRET_KEYS } from "./globalState"
44
export function checkExistKey(config: ApiConfiguration | undefined) {
55
if (!config) return false
66

7-
// Special case for human-relay and fake-ai providers which don't need any configuration
8-
if (config.apiProvider === "human-relay" || config.apiProvider === "fake-ai") {
7+
// Special case for providers that don't need configuration in the apiConfiguration object
8+
if (config.apiProvider === "human-relay" || config.apiProvider === "fake-ai" || config.apiProvider === "pearai") {
99
return true
1010
}
1111

src/shared/globalState.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ export const SECRET_KEYS = [
2626
"mistralApiKey",
2727
"unboundApiKey",
2828
"requestyApiKey",
29-
"pearaiToken",
30-
"pearaiRefresh",
29+
"pearaiApiKey",
3130
] as const
3231

3332
// type CheckSecretKeysExhaustiveness = Exclude<SecretKey, (typeof SECRET_KEYS)[number]> extends never ? true : false
@@ -129,7 +128,6 @@ export const GLOBAL_STATE_KEYS = [
129128
"pearaiModelId",
130129
"pearaiModelInfo",
131130
"pearaiBaseUrl",
132-
"pearaiApiKey",
133131
] as const
134132

135133
export const PASS_THROUGH_STATE_KEYS = ["taskHistory"] as const

webview-ui/src/context/ExtensionStateContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
202202
}))
203203
const config = newState.apiConfiguration
204204
const hasKey = checkExistKey(config)
205-
if (!hasKey) {
205+
if (!hasKey && (!config || config.apiProvider !== "pearai")) {
206206
vscode.postMessage({
207207
type: "apiConfiguration",
208208
apiConfiguration: {

0 commit comments

Comments
 (0)