fix: create new Requesty profile during OAuth (#8699)

Co-authored-by: John Costa <john@requesty.ai>
This commit is contained in:
Thibault Jaigu 2025-11-02 05:07:16 +00:00 committed by GitHub
parent 25c6f46e71
commit ca10cba3c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 30 additions and 21 deletions

View file

@ -30,8 +30,9 @@ export const handleUri = async (uri: vscode.Uri) => {
}
case "/requesty": {
const code = query.get("code")
const baseUrl = query.get("baseUrl")
if (code) {
await visibleProvider.handleRequestyCallback(code)
await visibleProvider.handleRequestyCallback(code, baseUrl)
}
break
}

View file

@ -95,6 +95,7 @@ import type { ClineMessage } from "@roo-code/types"
import { readApiMessages, saveApiMessages, saveTaskMessages } from "../task-persistence"
import { getNonce } from "./getNonce"
import { getUri } from "./getUri"
import { REQUESTY_BASE_URL } from "../../shared/utils/requesty"
/**
* https://github.com/microsoft/vscode-webview-ui-toolkit-samples/blob/main/default/weather-webview/src/providers/WeatherViewProvider.ts
@ -1470,8 +1471,8 @@ export class ClineProvider
// Requesty
async handleRequestyCallback(code: string) {
let { apiConfiguration, currentApiConfigName = "default" } = await this.getState()
async handleRequestyCallback(code: string, baseUrl: string | null) {
let { apiConfiguration } = await this.getState()
const newConfiguration: ProviderSettings = {
...apiConfiguration,
@ -1480,7 +1481,16 @@ export class ClineProvider
requestyModelId: apiConfiguration?.requestyModelId || requestyDefaultModelId,
}
await this.upsertProviderProfile(currentApiConfigName, newConfiguration)
// set baseUrl as undefined if we don't provide one
// or if it is the default requesty url
if (!baseUrl || baseUrl === REQUESTY_BASE_URL) {
newConfiguration.requestyBaseUrl = undefined
} else {
newConfiguration.requestyBaseUrl = baseUrl
}
const profileName = `Requesty (${new Date().toLocaleString()})`
await this.upsertProviderProfile(profileName, newConfiguration)
}
// Task history

View file

@ -1,4 +1,4 @@
const REQUESTY_BASE_URL = "https://router.requesty.ai/v1"
export const REQUESTY_BASE_URL = "https://router.requesty.ai/v1"
type URLType = "router" | "app" | "api"

View file

@ -84,21 +84,19 @@ export const Requesty = ({
<div className="text-sm text-vscode-descriptionForeground -mt-2">
{t("settings:providers.apiKeyStorageNotice")}
</div>
{!apiConfiguration?.requestyApiKey && (
<a
href={getApiKeyUrl()}
target="_blank"
rel="noopener noreferrer"
className="inline-flex items-center justify-center whitespace-nowrap text-sm font-medium focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 bg-primary text-primary-foreground shadow hover:bg-primary/90 h-9 rounded-md px-3 w-full"
style={{
width: "100%",
textDecoration: "none",
color: "var(--vscode-button-foreground)",
backgroundColor: "var(--vscode-button-background)",
}}>
{t("settings:providers.getRequestyApiKey")}
</a>
)}
<a
href={getApiKeyUrl()}
target="_blank"
rel="noopener noreferrer"
className="inline-flex items-center justify-center whitespace-nowrap text-sm font-medium focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 bg-primary text-primary-foreground shadow hover:bg-primary/90 h-9 rounded-md px-3 w-full"
style={{
width: "100%",
textDecoration: "none",
color: "var(--vscode-button-foreground)",
backgroundColor: "var(--vscode-button-background)",
}}>
{t("settings:providers.getRequestyApiKey")}
</a>
<VSCodeCheckbox
checked={requestyEndpointSelected}

View file

@ -269,7 +269,7 @@
"success": "Models list refreshed successfully!",
"error": "Failed to refresh models list. Please try again."
},
"getRequestyApiKey": "Get Requesty API Key",
"getRequestyApiKey": "Create new Requesty API Key",
"getRequestyBaseUrl": "Base URL",
"requestyUseCustomBaseUrl": "Use custom base URL",
"openRouterTransformsText": "Compress prompts and message chains to the context size (<a>OpenRouter Transforms</a>)",