mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-21 12:51:17 -05:00
Refactor Kodu links
This commit is contained in:
@@ -1,23 +1,11 @@
|
||||
import { Anthropic } from "@anthropic-ai/sdk"
|
||||
import axios from "axios"
|
||||
import { ApiHandler, withoutImageData } from "."
|
||||
import { ApiHandlerOptions, koduDefaultModelId, KoduModelId, koduModels, ModelInfo } from "../shared/api"
|
||||
import axios from "axios"
|
||||
import * as vscode from "vscode"
|
||||
|
||||
const KODU_BASE_URL = "https://claude-dev.com"
|
||||
|
||||
export function didClickKoduSignIn() {
|
||||
const loginUrl = `${KODU_BASE_URL}/auth/login?redirectTo=${vscode.env.uriScheme}://saoudrizwan.claude-dev&ext=1`
|
||||
vscode.env.openExternal(vscode.Uri.parse(loginUrl))
|
||||
}
|
||||
|
||||
export function didClickKoduAddCredits() {
|
||||
const addCreditsUrl = `${KODU_BASE_URL}/user/addCredits?redirectTo=${vscode.env.uriScheme}://saoudrizwan.claude-dev&ext=1`
|
||||
vscode.env.openExternal(vscode.Uri.parse(addCreditsUrl))
|
||||
}
|
||||
import { getKoduCreditsUrl, getKoduInferenceUrl } from "../shared/kodu"
|
||||
|
||||
export async function fetchKoduCredits({ apiKey }: { apiKey: string }) {
|
||||
const response = await axios.get(`${KODU_BASE_URL}/api/credits`, {
|
||||
const response = await axios.get(getKoduCreditsUrl(), {
|
||||
headers: {
|
||||
"x-api-key": apiKey,
|
||||
},
|
||||
@@ -89,7 +77,7 @@ export class KoduHandler implements ApiHandler {
|
||||
tool_choice: { type: "auto" },
|
||||
}
|
||||
}
|
||||
const response = await axios.post(`${KODU_BASE_URL}/api/inference`, requestBody, {
|
||||
const response = await axios.post(getKoduInferenceUrl(), requestBody, {
|
||||
headers: {
|
||||
"x-api-key": this.options.koduApiKey,
|
||||
},
|
||||
|
||||
@@ -8,7 +8,7 @@ import { downloadTask, getNonce, getUri, selectImages } from "../utils"
|
||||
import * as path from "path"
|
||||
import fs from "fs/promises"
|
||||
import { HistoryItem } from "../shared/HistoryItem"
|
||||
import { didClickKoduAddCredits, didClickKoduSignIn, fetchKoduCredits } from "../api/kodu"
|
||||
import { fetchKoduCredits } from "../api/kodu"
|
||||
|
||||
/*
|
||||
https://github.com/microsoft/vscode-webview-ui-toolkit-samples/blob/main/default/weather-webview/src/providers/WeatherViewProvider.ts
|
||||
@@ -358,15 +358,9 @@ export class ClaudeDevProvider implements vscode.WebviewViewProvider {
|
||||
case "exportTaskWithId":
|
||||
this.exportTaskWithId(message.text!)
|
||||
break
|
||||
case "didClickKoduSignIn":
|
||||
didClickKoduSignIn()
|
||||
break
|
||||
case "didClickKoduSignOut":
|
||||
await this.signOutKodu()
|
||||
break
|
||||
case "didClickKoduAddCredits":
|
||||
didClickKoduAddCredits()
|
||||
break
|
||||
case "fetchKoduCredits":
|
||||
const koduApiKey = await this.getSecret("koduApiKey")
|
||||
if (koduApiKey) {
|
||||
@@ -515,6 +509,7 @@ export class ClaudeDevProvider implements vscode.WebviewViewProvider {
|
||||
customInstructions,
|
||||
alwaysAllowReadOnly,
|
||||
themeName: vscode.workspace.getConfiguration("workbench").get<string>("colorTheme"),
|
||||
uriScheme: vscode.env.uriScheme,
|
||||
claudeMessages: this.claudeDev?.claudeMessages || [],
|
||||
taskHistory: (taskHistory || []).filter((item) => item.ts && item.task).sort((a, b) => b.ts - a.ts),
|
||||
shouldShowAnnouncement: lastShownAnnouncementId !== this.latestAnnouncementId,
|
||||
|
||||
@@ -25,6 +25,7 @@ export interface ExtensionState {
|
||||
customInstructions?: string
|
||||
alwaysAllowReadOnly?: boolean
|
||||
themeName?: string
|
||||
uriScheme?: string
|
||||
claudeMessages: ClaudeMessage[]
|
||||
taskHistory: HistoryItem[]
|
||||
shouldShowAnnouncement: boolean
|
||||
|
||||
@@ -16,9 +16,7 @@ export interface WebviewMessage {
|
||||
| "showTaskWithId"
|
||||
| "deleteTaskWithId"
|
||||
| "exportTaskWithId"
|
||||
| "didClickKoduSignIn"
|
||||
| "didClickKoduSignOut"
|
||||
| "didClickKoduAddCredits"
|
||||
| "fetchKoduCredits"
|
||||
text?: string
|
||||
askResponse?: ClaudeAskResponse
|
||||
|
||||
17
src/shared/kodu.ts
Normal file
17
src/shared/kodu.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
const KODU_BASE_URL = "https://claude-dev.com"
|
||||
|
||||
export function getKoduSignInUrl(uriScheme?: string) {
|
||||
return `${KODU_BASE_URL}/auth/login?redirectTo=${uriScheme}://saoudrizwan.claude-dev&ext=1`
|
||||
}
|
||||
|
||||
export function getKoduAddCreditsUrl(uriScheme?: string) {
|
||||
return `${KODU_BASE_URL}/user/addCredits?redirectTo=${uriScheme}://saoudrizwan.claude-dev&ext=1`
|
||||
}
|
||||
|
||||
export function getKoduCreditsUrl() {
|
||||
return `${KODU_BASE_URL}/api/credits`
|
||||
}
|
||||
|
||||
export function getKoduInferenceUrl() {
|
||||
return `${KODU_BASE_URL}/api/inference`
|
||||
}
|
||||
Reference in New Issue
Block a user