mirror of
https://github.com/cline/cline.git
synced 2026-10-30 18:12:49 +08:00
Centralize the API url (#77)
* Centralize the API url * Export constant in the index.browser
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { ProviderSettings, ProviderSettingsManager } from "@cline/core";
|
||||
import { DEFAULT_CLINE_API_BASE_URL } from "@cline/shared";
|
||||
import type { OAuthCredentials } from "../commands/auth";
|
||||
import {
|
||||
getPersistedProviderApiKey,
|
||||
@@ -83,7 +84,8 @@ async function performOAuthLogin(
|
||||
|
||||
if (providerId === "cline") {
|
||||
return coreOAuth.loginClineOAuth({
|
||||
apiBaseUrl: existingSettings?.baseUrl?.trim() || "https://api.cline.bot",
|
||||
apiBaseUrl:
|
||||
existingSettings?.baseUrl?.trim() || DEFAULT_CLINE_API_BASE_URL,
|
||||
callbacks,
|
||||
useWorkOSDeviceAuth: true,
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
type ProviderSettings,
|
||||
type ProviderSettingsManager,
|
||||
} from "@cline/core";
|
||||
import { DEFAULT_CLINE_API_BASE_URL } from "@cline/shared";
|
||||
import { Command } from "commander";
|
||||
import open from "open";
|
||||
import React from "react";
|
||||
@@ -280,7 +281,7 @@ async function loginWithOAuthProvider(
|
||||
|
||||
if (providerId === "cline") {
|
||||
return oauthApi.loginClineOAuth({
|
||||
apiBaseUrl: existing?.baseUrl?.trim() || "https://api.cline.bot",
|
||||
apiBaseUrl: existing?.baseUrl?.trim() || DEFAULT_CLINE_API_BASE_URL,
|
||||
useWorkOSDeviceAuth: true,
|
||||
callbacks,
|
||||
});
|
||||
|
||||
@@ -8,11 +8,11 @@ import {
|
||||
type ProviderSettings,
|
||||
ProviderSettingsManager,
|
||||
} from "@cline/core";
|
||||
import { DEFAULT_CLINE_API_BASE_URL } from "@cline/shared";
|
||||
import { formatCreditBalance, normalizeCreditBalance } from "../utils/output";
|
||||
import { toProviderApiKey } from "../utils/provider-auth";
|
||||
import type { Config } from "../utils/types";
|
||||
|
||||
const DEFAULT_CLINE_API_BASE_URL = "https://api.cline.bot";
|
||||
const WORKOS_TOKEN_PREFIX = "workos:";
|
||||
|
||||
type ClineAccountConfig = Pick<Config, "apiKey" | "providerId">;
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
saveLocalProviderSettings,
|
||||
startClineDeviceAuth,
|
||||
} from "@cline/core";
|
||||
import { DEFAULT_CLINE_API_BASE_URL } from "@cline/shared";
|
||||
import type { ChoiceContext } from "@opentui-ui/dialog";
|
||||
import { useDialogKeyboard } from "@opentui-ui/dialog/react";
|
||||
import open from "open";
|
||||
@@ -454,7 +455,7 @@ export function OAuthLoginContent(
|
||||
|
||||
const manager = new ProviderSettingsManager();
|
||||
const existing = manager.getProviderSettings(providerId);
|
||||
const apiBaseUrl = existing?.baseUrl?.trim() || "https://api.cline.bot";
|
||||
const apiBaseUrl = existing?.baseUrl?.trim() || DEFAULT_CLINE_API_BASE_URL;
|
||||
|
||||
startClineDeviceAuth()
|
||||
.then((result) => {
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
saveLocalProviderOAuthCredentials,
|
||||
startClineDeviceAuth,
|
||||
} from "@cline/core";
|
||||
import { DEFAULT_CLINE_API_BASE_URL } from "@cline/shared";
|
||||
import open from "open";
|
||||
|
||||
export type OnboardingOAuthProviderId = "cline" | "oca" | "openai-codex";
|
||||
@@ -73,7 +74,7 @@ export function runDeviceCodeAuthFlow(input: {
|
||||
const existing = input.providerSettingsManager.getProviderSettings(
|
||||
input.providerId,
|
||||
);
|
||||
const apiBaseUrl = existing?.baseUrl?.trim() || "https://api.cline.bot";
|
||||
const apiBaseUrl = existing?.baseUrl?.trim() || DEFAULT_CLINE_API_BASE_URL;
|
||||
|
||||
startClineDeviceAuth()
|
||||
.then((result) => {
|
||||
|
||||
@@ -14,10 +14,9 @@ import {
|
||||
readEnterpriseSessionBlobUploadMetadata,
|
||||
registerEnterpriseSessionBlobUpload,
|
||||
} from "@cline/enterprise";
|
||||
import { RemoteConfigSchema } from "@cline/shared";
|
||||
import { DEFAULT_CLINE_API_BASE_URL, RemoteConfigSchema } from "@cline/shared";
|
||||
import { getCliTelemetryService } from "./telemetry";
|
||||
|
||||
const DEFAULT_CLINE_API_BASE_URL = "https://api.cline.bot";
|
||||
const initializedRemoteConfigKeys = new Set<string>();
|
||||
|
||||
async function loadCliRemoteConfigBundle(): Promise<
|
||||
|
||||
@@ -46,6 +46,7 @@ import {
|
||||
setDisabledTools,
|
||||
toggleDisabledTool,
|
||||
} from "@cline/core";
|
||||
import { DEFAULT_CLINE_API_BASE_URL } from "@cline/shared";
|
||||
import { broadcastEvent, resolveSidecarAskQuestion } from "./context";
|
||||
import {
|
||||
findArtifactUnderDir,
|
||||
@@ -926,7 +927,7 @@ export async function handleCommand(
|
||||
const manager = new ProviderSettingsManager();
|
||||
const settings = manager.getProviderSettings("cline");
|
||||
const accountService = new ClineAccountService({
|
||||
apiBaseUrl: settings?.baseUrl?.trim() || "https://api.cline.bot",
|
||||
apiBaseUrl: settings?.baseUrl?.trim() || DEFAULT_CLINE_API_BASE_URL,
|
||||
getAuthToken: async () => resolveLocalClineAuthToken(settings),
|
||||
});
|
||||
return await executeClineAccountAction(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
DEFAULT_CLINE_API_BASE_URL,
|
||||
type ITelemetryService,
|
||||
isOAuthProviderId,
|
||||
type OAuthProviderId,
|
||||
@@ -13,7 +14,6 @@ import { decodeJwtPayload } from "../../auth/utils";
|
||||
import { ProviderSettingsManager } from "../../services/storage/provider-settings-manager";
|
||||
import type { ProviderSettings } from "../../types/provider-settings";
|
||||
|
||||
const DEFAULT_CLINE_API_BASE_URL = "https://api.cline.bot";
|
||||
const WORKOS_TOKEN_PREFIX = "workos:";
|
||||
|
||||
type ManagedOAuthProviderId = OAuthProviderId;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { DEFAULT_CLINE_API_BASE_URL } from "@cline/shared";
|
||||
import { ProviderSettingsManager } from "../storage/provider-settings-manager";
|
||||
|
||||
export interface ClineRecommendedModel {
|
||||
@@ -22,7 +23,7 @@ export interface FetchClineRecommendedModelsOptions {
|
||||
timeoutMs?: number;
|
||||
}
|
||||
|
||||
const DEFAULT_API_BASE_URL = "https://api.cline.bot";
|
||||
const DEFAULT_API_BASE_URL = DEFAULT_CLINE_API_BASE_URL;
|
||||
const DEFAULT_REQUEST_TIMEOUT_MS = 5_000;
|
||||
|
||||
export const FALLBACK_CLINE_RECOMMENDED_MODELS: ClineRecommendedModelsData = {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import * as LlmsModels from "@cline/llms";
|
||||
import {
|
||||
type AddProviderActionRequest,
|
||||
DEFAULT_CLINE_API_BASE_URL,
|
||||
isOAuthProviderId,
|
||||
type OAuthProviderId,
|
||||
type ProviderCapability,
|
||||
@@ -701,7 +702,7 @@ export async function loginLocalProvider(
|
||||
|
||||
if (providerId === "cline") {
|
||||
return loginClineOAuth({
|
||||
apiBaseUrl: existing?.baseUrl?.trim() || "https://api.cline.bot",
|
||||
apiBaseUrl: existing?.baseUrl?.trim() || DEFAULT_CLINE_API_BASE_URL,
|
||||
useWorkOSDeviceAuth: true,
|
||||
callbacks,
|
||||
});
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import type {
|
||||
GatewayModelCapability,
|
||||
GatewayModelDefinition,
|
||||
GatewayProviderManifest,
|
||||
GatewayProviderMetadata,
|
||||
GatewayProviderSettings,
|
||||
JsonValue,
|
||||
ProviderCapability,
|
||||
import {
|
||||
DEFAULT_CLINE_API_BASE_URL,
|
||||
type GatewayModelCapability,
|
||||
type GatewayModelDefinition,
|
||||
type GatewayProviderManifest,
|
||||
type GatewayProviderMetadata,
|
||||
type GatewayProviderSettings,
|
||||
type JsonValue,
|
||||
type ProviderCapability,
|
||||
} from "@cline/shared";
|
||||
import { getGeneratedModelsForProvider } from "../catalog/catalog.generated-access";
|
||||
import type {
|
||||
@@ -215,7 +216,7 @@ const OPENAI_COMPATIBLE_SPECS: BuiltinSpec[] = [
|
||||
modelsProviderId: "openrouter",
|
||||
defaultModelId: "anthropic/claude-sonnet-4.6",
|
||||
apiKeyEnv: ["CLINE_API_KEY"],
|
||||
defaults: { baseUrl: "https://api.cline.bot/api/v1" },
|
||||
defaults: { baseUrl: `${DEFAULT_CLINE_API_BASE_URL}/api/v1` },
|
||||
metadata: { promptCacheStrategy: "anthropic-automatic" },
|
||||
},
|
||||
{
|
||||
|
||||
@@ -125,7 +125,11 @@ export {
|
||||
resolveReasoningBudgetFromRatio,
|
||||
resolveReasoningEffortRatio,
|
||||
} from "./llms/reasoning-effort";
|
||||
export { DEFAULT_REQUEST_HEADERS, serializeAbortReason } from "./llms/requests";
|
||||
export {
|
||||
DEFAULT_CLINE_API_BASE_URL,
|
||||
DEFAULT_REQUEST_HEADERS,
|
||||
serializeAbortReason,
|
||||
} from "./llms/requests";
|
||||
export type {
|
||||
ToolApprovalRequest,
|
||||
ToolApprovalResult,
|
||||
|
||||
@@ -139,7 +139,11 @@ export {
|
||||
resolveReasoningBudgetFromRatio,
|
||||
resolveReasoningEffortRatio,
|
||||
} from "./llms/reasoning-effort";
|
||||
export { DEFAULT_REQUEST_HEADERS, serializeAbortReason } from "./llms/requests";
|
||||
export {
|
||||
DEFAULT_CLINE_API_BASE_URL,
|
||||
DEFAULT_REQUEST_HEADERS,
|
||||
serializeAbortReason,
|
||||
} from "./llms/requests";
|
||||
export type {
|
||||
ToolApprovalRequest,
|
||||
ToolApprovalResult,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
export const DEFAULT_CLINE_API_BASE_URL = "https://api.cline.bot";
|
||||
|
||||
export const DEFAULT_REQUEST_HEADERS: Record<string, string> = {
|
||||
"HTTP-Referer": "https://cline.bot",
|
||||
"X-Title": "Cline",
|
||||
|
||||
Reference in New Issue
Block a user