Skip to content

Commit b00d1ea

Browse files
committed
Added login logout p2p call working
1 parent fada5e2 commit b00d1ea

9 files changed

Lines changed: 77 additions & 43 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"name": "roo-cline",
3-
"displayName": "Roo Code (prev. Roo Cline)",
4-
"description": "A VS Code plugin that enhances coding with AI-powered automation, multi-model support, and experimental features.",
5-
"publisher": "RooVeterinaryInc",
2+
"name": "pearai-roo-cline",
3+
"displayName": "PearAI Roo Code / Cline",
4+
"description": "PearAI's integration of Roo Code / Cline, a coding agent.",
5+
"publisher": "PearAI",
66
"version": "3.3.4",
77
"icon": "assets/icons/rocket.png",
88
"galleryBanner": {
@@ -13,7 +13,7 @@
1313
"vscode": "^1.84.0"
1414
},
1515
"author": {
16-
"name": "Roo Vet"
16+
"name": "PearAI"
1717
},
1818
"repository": {
1919
"type": "git",

src/core/webview/ClineProvider.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ import { CustomSupportPrompts, supportPrompt } from "../../shared/support-prompt
4545

4646
import { ACTION_NAMES } from "../CodeActionProvider"
4747

48-
// Todo: Remove
49-
const PEARAI_TOKEN = "temp"
50-
5148
/*
5249
https://github.com/microsoft/vscode-webview-ui-toolkit-samples/blob/main/default/weather-webview/src/providers/WeatherViewProvider.ts
5350
@@ -66,7 +63,8 @@ type SecretKey =
6663
| "openAiNativeApiKey"
6764
| "deepSeekApiKey"
6865
| "mistralApiKey"
69-
| "pearaiApiKey"
66+
| "pearai-token"
67+
| "pearai-refresh" // Array of custom modes
7068
type GlobalStateKey =
7169
| "apiProvider"
7270
| "apiModelId"
@@ -130,8 +128,6 @@ type GlobalStateKey =
130128
| "experiments" // Map of experiment IDs to their enabled state
131129
| "autoApprovalEnabled"
132130
| "customModes"
133-
| "pearai-token"
134-
| "pearai-refresh" // Array of custom modes
135131

136132
export const GlobalFileNames = {
137133
apiConversationHistory: "api_conversation_history.json",
@@ -1278,6 +1274,19 @@ export class ClineProvider implements vscode.WebviewViewProvider {
12781274
await this.updateGlobalState("mode", defaultModeSlug)
12791275
await this.postStateToWebview()
12801276
}
1277+
break
1278+
case "openPearAiAuth":
1279+
const extensionUrl = `${vscode.env.uriScheme}://pearai.pearai/auth`
1280+
const callbackUri = await vscode.env.asExternalUri(vscode.Uri.parse(extensionUrl))
1281+
1282+
await vscode.env.openExternal(
1283+
await vscode.env.asExternalUri(
1284+
vscode.Uri.parse(
1285+
`https://trypear.ai/signin?callback=${callbackUri.toString()}`, // Change to localhost if running locally
1286+
),
1287+
),
1288+
)
1289+
break
12811290
}
12821291
},
12831292
null,
@@ -1373,7 +1382,6 @@ export class ClineProvider implements vscode.WebviewViewProvider {
13731382
openRouterUseMiddleOutTransform,
13741383
vsCodeLmModelSelector,
13751384
mistralApiKey,
1376-
pearaiApiKey,
13771385
pearaiBaseUrl,
13781386
pearaiModelId,
13791387
pearaiModelInfo,
@@ -1415,7 +1423,6 @@ export class ClineProvider implements vscode.WebviewViewProvider {
14151423
await this.updateGlobalState("openRouterUseMiddleOutTransform", openRouterUseMiddleOutTransform)
14161424
await this.updateGlobalState("vsCodeLmModelSelector", vsCodeLmModelSelector)
14171425
await this.storeSecret("mistralApiKey", mistralApiKey)
1418-
await this.updateGlobalState("pearai-token", PEARAI_TOKEN)
14191426
await this.updateGlobalState("pearaiBaseUrl", PEARAI_URL)
14201427
await this.updateGlobalState("pearaiModelId", pearaiModelId)
14211428
await this.updateGlobalState("pearaiModelInfo", pearaiModelInfo)
@@ -2112,8 +2119,8 @@ export class ClineProvider implements vscode.WebviewViewProvider {
21122119
this.getSecret("openAiNativeApiKey") as Promise<string | undefined>,
21132120
this.getSecret("deepSeekApiKey") as Promise<string | undefined>,
21142121
this.getSecret("mistralApiKey") as Promise<string | undefined>,
2115-
this.getGlobalState("pearai-token") as Promise<string | undefined>,
2116-
this.getGlobalState("pearai-refresh") as Promise<string | undefined>,
2122+
this.getSecret("pearai-token") as Promise<string | undefined>,
2123+
this.getSecret("pearai-refresh") as Promise<string | undefined>,
21172124
this.getGlobalState("pearaiBaseUrl") as Promise<string | undefined>,
21182125
this.getGlobalState("pearaiModelId") as Promise<string | undefined>,
21192126
this.getGlobalState("pearaiModelInfo") as Promise<ModelInfo | undefined>,

src/extension.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,23 @@ export function activate(context: vscode.ExtensionContext) {
5252
}),
5353
)
5454

55+
context.subscriptions.push(
56+
vscode.commands.registerCommand("pearai-roo-cline.pearaiLogin", async (data) => {
57+
console.dir("Logged in to PearAI:")
58+
console.dir(data)
59+
context.secrets.store("pearai-token", data.accessToken)
60+
context.secrets.store("pearai-refresh", data.refreshToken)
61+
}),
62+
)
63+
64+
context.subscriptions.push(
65+
vscode.commands.registerCommand("pearai-roo-cline.pearAILogout", async () => {
66+
console.dir("Logged out of PearAI:")
67+
context.secrets.delete("pearai-token")
68+
context.secrets.delete("pearai-refresh")
69+
}),
70+
)
71+
5572
context.subscriptions.push(
5673
vscode.commands.registerCommand("roo-cline.mcpButtonClicked", () => {
5774
sidebarProvider.postMessageToWebview({ type: "action", action: "mcpButtonClicked" })

src/shared/ExtensionMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export interface ExtensionMessage {
5050
| "historyButtonClicked"
5151
| "promptsButtonClicked"
5252
| "didBecomeVisible"
53+
| "updatePearAIAuth"
5354
invoke?: "sendMessage" | "primaryButtonClick" | "secondaryButtonClick"
5455
state?: ExtensionState
5556
images?: string[]

src/shared/WebviewMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export interface WebviewMessage {
8181
| "deleteCustomMode"
8282
| "setopenAiCustomModelInfo"
8383
| "openCustomModesSettings"
84+
| "openPearAiAuth"
8485
text?: string
8586
disabled?: boolean
8687
askResponse?: ClineAskResponse

src/shared/checkExistApiConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ export function checkExistKey(config: ApiConfiguration | undefined) {
44
return config
55
? [
66
config.apiKey,
7-
config.pearaiApiKey,
87
config.glamaApiKey,
98
config.openRouterApiKey,
109
config.awsRegion,
@@ -17,6 +16,7 @@ export function checkExistKey(config: ApiConfiguration | undefined) {
1716
config.deepSeekApiKey,
1817
config.mistralApiKey,
1918
config.vsCodeLmModelSelector,
19+
config.pearaiBaseUrl,
2020
].some((key) => key !== undefined)
2121
: false
2222
}

webview-ui/src/components/settings/ApiOptions.tsx

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import {
3232
openRouterDefaultModelInfo,
3333
vertexDefaultModelId,
3434
vertexModels,
35-
PEARAI_URL,
3635
} from "../../../../src/shared/api"
3736
import { ExtensionMessage } from "../../../../src/shared/ExtensionMessage"
3837
import { useExtensionState } from "../../context/ExtensionStateContext"
@@ -161,20 +160,35 @@ const ApiOptions = ({ apiErrorMessage, modelIdErrorMessage }: ApiOptionsProps) =
161160

162161
{selectedProvider === "pearai" && (
163162
<div>
164-
<VSCodeTextField
165-
value={apiConfiguration?.pearaiApiKey || ""}
166-
style={{ width: "100%" }}
167-
type="password"
168-
onInput={handleInputChange("pearaiApiKey")}
169-
placeholder="Enter API Key...">
170-
<span style={{ fontWeight: 500 }}>PearAI API Key</span>
171-
</VSCodeTextField>
172-
<p
173-
style={{
174-
fontSize: "12px",
175-
marginTop: "5px",
176-
color: "var(--vscode-descriptionForeground)",
177-
}}></p>
163+
{!apiConfiguration?.pearaiApiKey ? (
164+
<>
165+
<VSCodeButton
166+
onClick={() => {
167+
vscode.postMessage({
168+
type: "openPearAiAuth",
169+
})
170+
}}>
171+
Login to PearAI
172+
</VSCodeButton>
173+
<p
174+
style={{
175+
fontSize: "12px",
176+
marginTop: "5px",
177+
color: "var(--vscode-descriptionForeground)",
178+
}}>
179+
Connect your PearAI account to use servers.
180+
</p>
181+
</>
182+
) : (
183+
<p
184+
style={{
185+
fontSize: "12px",
186+
marginTop: "5px",
187+
color: "var(--vscode-descriptionForeground)",
188+
}}>
189+
User already logged in to PearAI. Click 'Done' to proceed!
190+
</p>
191+
)}
178192
</div>
179193
)}
180194

webview-ui/src/components/welcome/WelcomeView.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,26 @@
11
import { VSCodeButton } from "@vscode/webview-ui-toolkit/react"
2-
import { useExtensionState } from "../../context/ExtensionStateContext"
32
import { vscode } from "../../utils/vscode"
3+
import { PEARAI_URL } from "../../../../src/shared/api"
44

55
const WelcomeView = () => {
66
const handleSubmit = () => {
77
vscode.postMessage({
88
type: "apiConfiguration",
99
apiConfiguration: {
1010
apiProvider: "pearai",
11-
pearaiApiKey: "temp", // TODO: Change this to use api-key
12-
pearaiBaseUrl: "http://localhost:8000/integrations/cline",
11+
pearaiBaseUrl: `${PEARAI_URL}/integrations/cline`,
1312
},
1413
})
1514
}
1615

1716
return (
1817
<div style={{ position: "fixed", top: 0, left: 0, right: 0, bottom: 0, padding: "0 20px" }}>
1918
<h2>Welcome to PearAI's Coding Agent (Powered by Roo Code / Cline)!</h2>
20-
<p>
21-
I can do all kinds of tasks thanks to the latest breakthroughs in agentic coding capabilities and access
22-
to tools that let me create & edit files, explore complex projects, use the browser, and execute
23-
terminal commands (with your permission, of course). I can even use MCP to create new tools and extend
24-
my own capabilities.
25-
</p>
19+
<p>Ask me to code new features or fix bugs!</p>
2620

2721
<div style={{ marginTop: "10px" }}>
2822
<VSCodeButton onClick={handleSubmit} style={{ marginTop: "3px" }}>
29-
Let's go!
23+
Proceed
3024
</VSCodeButton>
3125
</div>
3226
</div>

0 commit comments

Comments
 (0)