Skip to content

Commit 15513f4

Browse files
authored
Merge pull request #360 from punkpeye/pkce
feat: Glama add pkce
2 parents ef8d02d + f759398 commit 15513f4

File tree

6 files changed

+53
-11
lines changed

6 files changed

+53
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ Once your merge is successful:
143143
<table>
144144
<tbody>
145145
<td align="center">
146-
<a href="https://marketplace.visualstudio.com/items?itemName=saoudrizwan.claude-dev" target="_blank"><strong>Download on VS Marketplace</strong></a>
146+
<a href="https://marketplace.visualstudio.com/items?itemName=rooveterinaryinc.roo-cline" target="_blank"><strong>Download on VS Marketplace</strong></a>
147147
</td>
148148
<td align="center">
149149
<a href="https://discord.gg/cline" target="_blank"><strong>Join the Discord</strong></a>

src/core/webview/ClineProvider.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,33 @@ export class ClineProvider implements vscode.WebviewViewProvider {
12731273
return cacheDir
12741274
}
12751275

1276+
async handleGlamaCallback(code: string) {
1277+
let apiKey: string
1278+
try {
1279+
const response = await axios.post("https://glama.ai/api/gateway/v1/auth/exchange-code", { code })
1280+
if (response.data && response.data.apiKey) {
1281+
apiKey = response.data.apiKey
1282+
} else {
1283+
throw new Error("Invalid response from Glama API")
1284+
}
1285+
} catch (error) {
1286+
console.error("Error exchanging code for API key:", error)
1287+
throw error
1288+
}
1289+
1290+
const glama: ApiProvider = "glama"
1291+
await this.updateGlobalState("apiProvider", glama)
1292+
await this.storeSecret("glamaApiKey", apiKey)
1293+
await this.postStateToWebview()
1294+
if (this.cline) {
1295+
this.cline.api = buildApiHandler({
1296+
apiProvider: glama,
1297+
glamaApiKey: apiKey,
1298+
})
1299+
}
1300+
// await this.postMessageToWebview({ type: "action", action: "settingsButtonClicked" }) // bad ux if user is on welcome
1301+
}
1302+
12761303
async readGlamaModels(): Promise<Record<string, ModelInfo> | undefined> {
12771304
const glamaModelsFilePath = path.join(
12781305
await this.ensureCacheDirectoryExists(),

src/exports/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ The Cline extension exposes an API that can be used by other extensions. To use
77
3. Get access to the API with the following code:
88

99
```ts
10-
const clineExtension = vscode.extensions.getExtension<ClineAPI>("saoudrizwan.claude-dev")
10+
const clineExtension = vscode.extensions.getExtension<ClineAPI>("rooveterinaryinc.roo-cline")
1111

1212
if (!clineExtension?.isActive) {
1313
throw new Error("Cline extension is not activated")
@@ -44,11 +44,11 @@ The Cline extension exposes an API that can be used by other extensions. To use
4444
}
4545
```
4646

47-
**Note:** To ensure that the `saoudrizwan.claude-dev` extension is activated before your extension, add it to the `extensionDependencies` in your `package.json`:
47+
**Note:** To ensure that the `rooveterinaryinc.roo-cline` extension is activated before your extension, add it to the `extensionDependencies` in your `package.json`:
4848

4949
```json
5050
"extensionDependencies": [
51-
"saoudrizwan.claude-dev"
51+
"rooveterinaryinc.roo-cline"
5252
]
5353
```
5454

src/extension.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ export function activate(context: vscode.ExtensionContext) {
139139
return
140140
}
141141
switch (path) {
142+
case "/glama": {
143+
const code = query.get("code")
144+
if (code) {
145+
await visibleProvider.handleGlamaCallback(code)
146+
}
147+
break
148+
}
149+
142150
case "/openrouter": {
143151
const code = query.get("code")
144152
if (code) {

src/integrations/theme/getTheme.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,5 +141,5 @@ export function mergeJson(
141141
}
142142

143143
function getExtensionUri(): vscode.Uri {
144-
return vscode.extensions.getExtension("saoudrizwan.claude-dev")!.extensionUri
144+
return vscode.extensions.getExtension("rooveterinaryinc.roo-cline")!.extensionUri
145145
}

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,12 @@ const ApiOptions = ({ apiErrorMessage, modelIdErrorMessage }: ApiOptionsProps) =
209209
<span style={{ fontWeight: 500 }}>Glama API Key</span>
210210
</VSCodeTextField>
211211
{!apiConfiguration?.glamaApiKey && (
212-
<VSCodeLink
213-
href="https://glama.ai/settings/api-keys"
214-
style={{ display: "inline", fontSize: "inherit" }}>
215-
You can get an Glama API key by signing up here.
216-
</VSCodeLink>
212+
<VSCodeButtonLink
213+
href={getGlamaAuthUrl(uriScheme)}
214+
style={{ margin: "5px 0 0 0" }}
215+
appearance="secondary">
216+
Get Glama API Key
217+
</VSCodeButtonLink>
217218
)}
218219
<p
219220
style={{
@@ -739,8 +740,14 @@ const ApiOptions = ({ apiErrorMessage, modelIdErrorMessage }: ApiOptionsProps) =
739740
)
740741
}
741742

743+
export function getGlamaAuthUrl(uriScheme?: string) {
744+
const callbackUrl = `${uriScheme || "vscode"}://rooveterinaryinc.roo-cline/glama`
745+
746+
return `https://glama.ai/oauth/authorize?callback_url=${encodeURIComponent(callbackUrl)}`
747+
}
748+
742749
export function getOpenRouterAuthUrl(uriScheme?: string) {
743-
return `https://openrouter.ai/auth?callback_url=${uriScheme || "vscode"}://saoudrizwan.claude-dev/openrouter`
750+
return `https://openrouter.ai/auth?callback_url=${uriScheme || "vscode"}://rooveterinaryinc.roo-cline/openrouter`
744751
}
745752

746753
export const formatPrice = (price: number) => {

0 commit comments

Comments
 (0)