Initial commit
This commit is contained in:
142
src/shared/constants/cliTools.js
Normal file
142
src/shared/constants/cliTools.js
Normal file
@@ -0,0 +1,142 @@
|
||||
// CLI Tools configuration
|
||||
export const CLI_TOOLS = {
|
||||
claude: {
|
||||
id: "claude",
|
||||
name: "Claude Code",
|
||||
icon: "terminal",
|
||||
color: "#D97757",
|
||||
description: "Anthropic Claude Code CLI",
|
||||
configType: "env",
|
||||
envVars: {
|
||||
baseUrl: "ANTHROPIC_BASE_URL",
|
||||
model: "ANTHROPIC_MODEL",
|
||||
opusModel: "ANTHROPIC_DEFAULT_OPUS_MODEL",
|
||||
sonnetModel: "ANTHROPIC_DEFAULT_SONNET_MODEL",
|
||||
haikuModel: "ANTHROPIC_DEFAULT_HAIKU_MODEL",
|
||||
},
|
||||
modelAliases: ["default", "sonnet", "opus", "haiku", "opusplan"],
|
||||
settingsFile: "~/.claude/settings.json",
|
||||
defaultModels: [
|
||||
{ id: "opus", name: "Claude Opus", alias: "opus", envKey: "ANTHROPIC_DEFAULT_OPUS_MODEL", defaultValue: "cc/claude-opus-4-5-20251101" },
|
||||
{ id: "sonnet", name: "Claude Sonnet", alias: "sonnet", envKey: "ANTHROPIC_DEFAULT_SONNET_MODEL", defaultValue: "cc/claude-sonnet-4-5-20250929" },
|
||||
{ id: "haiku", name: "Claude Haiku", alias: "haiku", envKey: "ANTHROPIC_DEFAULT_HAIKU_MODEL", defaultValue: "cc/claude-haiku-4-5-20251001" },
|
||||
],
|
||||
},
|
||||
codex: {
|
||||
id: "codex",
|
||||
name: "OpenAI Codex CLI",
|
||||
image: "/providers/codex.png",
|
||||
color: "#10A37F",
|
||||
description: "OpenAI Codex CLI",
|
||||
configType: "custom",
|
||||
},
|
||||
cursor: {
|
||||
id: "cursor",
|
||||
name: "Cursor",
|
||||
image: "/providers/cursor.png",
|
||||
color: "#000000",
|
||||
description: "Cursor AI Code Editor",
|
||||
configType: "guide",
|
||||
requiresCloud: true,
|
||||
notes: [
|
||||
{ type: "warning", text: "Requires Cursor Pro account to use this feature." },
|
||||
{ type: "cloudCheck", text: "Cursor routes requests through its own server, so local endpoint is not supported. Please enable Cloud Endpoint in Settings." },
|
||||
],
|
||||
guideSteps: [
|
||||
{ step: 1, title: "Open Settings", desc: "Go to Settings → Models" },
|
||||
{ step: 2, title: "Enable OpenAI API", desc: "Enable \"OpenAI API key\" option" },
|
||||
{ step: 3, title: "Base URL", value: "{{baseUrl}}/v1", copyable: true },
|
||||
{ step: 4, title: "API Key", type: "apiKeySelector" },
|
||||
{ step: 5, title: "Add Custom Model", desc: "Click \"View All Model\" → \"Add Custom Model\"" },
|
||||
{ step: 6, title: "Select Model", type: "modelSelector" },
|
||||
],
|
||||
},
|
||||
cline: {
|
||||
id: "cline",
|
||||
name: "CLINE",
|
||||
image: "/providers/cline.png",
|
||||
color: "#00D1B2",
|
||||
description: "CLINE AI Assistant",
|
||||
configType: "guide",
|
||||
guideSteps: [
|
||||
{ step: 1, title: "Open Settings", desc: "Go to CLINE Settings panel" },
|
||||
{ step: 2, title: "Select Provider", desc: "Choose API Provider → Ollama" },
|
||||
{ step: 3, title: "Base URL", value: "{{baseUrl}}", copyable: true },
|
||||
{ step: 4, title: "API Key", type: "apiKeySelector" },
|
||||
{ step: 5, title: "Select Model", type: "modelSelector" },
|
||||
],
|
||||
},
|
||||
roo: {
|
||||
id: "roo",
|
||||
name: "Roo",
|
||||
image: "/providers/roo.png",
|
||||
color: "#FF6B6B",
|
||||
description: "Roo AI Assistant",
|
||||
configType: "guide",
|
||||
guideSteps: [
|
||||
{ step: 1, title: "Open Settings", desc: "Go to Roo Settings panel" },
|
||||
{ step: 2, title: "Select Provider", desc: "Choose API Provider → Ollama" },
|
||||
{ step: 3, title: "Base URL", value: "{{baseUrl}}", copyable: true },
|
||||
{ step: 4, title: "API Key", type: "apiKeySelector" },
|
||||
{ step: 5, title: "Select Model", type: "modelSelector" },
|
||||
],
|
||||
},
|
||||
continue: {
|
||||
id: "continue",
|
||||
name: "Continue",
|
||||
image: "/providers/continue.png",
|
||||
color: "#7C3AED",
|
||||
description: "Continue AI Assistant",
|
||||
configType: "guide",
|
||||
guideSteps: [
|
||||
{ step: 1, title: "Open Config", desc: "Open Continue configuration file" },
|
||||
{ step: 2, title: "API Key", type: "apiKeySelector" },
|
||||
{ step: 3, title: "Select Model", type: "modelSelector" },
|
||||
{ step: 4, title: "Add Model Config", desc: "Add the following configuration to your models array:" },
|
||||
],
|
||||
codeBlock: {
|
||||
language: "json",
|
||||
code: `{
|
||||
"apiBase": "{{baseUrl}}",
|
||||
"title": "{{model}}",
|
||||
"model": "{{model}}",
|
||||
"provider": "openai",
|
||||
"apiKey": "{{apiKey}}"
|
||||
}`,
|
||||
},
|
||||
},
|
||||
// HIDDEN: gemini-cli
|
||||
// "gemini-cli": {
|
||||
// id: "gemini-cli",
|
||||
// name: "Gemini CLI",
|
||||
// icon: "terminal",
|
||||
// color: "#4285F4",
|
||||
// description: "Google Gemini CLI",
|
||||
// configType: "env",
|
||||
// envVars: {
|
||||
// baseUrl: "GEMINI_API_BASE_URL",
|
||||
// model: "GEMINI_MODEL",
|
||||
// },
|
||||
// defaultModels: [
|
||||
// { id: "gemini-2.5-pro", name: "Gemini 2.5 Pro", alias: "pro" },
|
||||
// { id: "gemini-2.5-flash", name: "Gemini 2.5 Flash", alias: "flash" },
|
||||
// ],
|
||||
// },
|
||||
};
|
||||
|
||||
// Get all provider models for mapping dropdown
|
||||
export const getProviderModelsForMapping = (providers) => {
|
||||
const result = [];
|
||||
providers.forEach(conn => {
|
||||
if (conn.isActive && (conn.testStatus === "active" || conn.testStatus === "success")) {
|
||||
result.push({
|
||||
connectionId: conn.id,
|
||||
provider: conn.provider,
|
||||
name: conn.name,
|
||||
models: conn.models || [],
|
||||
});
|
||||
}
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
77
src/shared/constants/colors.js
Normal file
77
src/shared/constants/colors.js
Normal file
@@ -0,0 +1,77 @@
|
||||
// Claude-inspired color palette for Endpoint Proxy
|
||||
// Light theme: Warm beige/cream tones
|
||||
// Dark theme: Deep charcoal/brown tones
|
||||
|
||||
export const COLORS = {
|
||||
// Primary - Warm Coral/Terracotta (Claude-like)
|
||||
primary: {
|
||||
DEFAULT: "#D97757",
|
||||
hover: "#C56243",
|
||||
light: "#E8A58C",
|
||||
dark: "#B0664D",
|
||||
},
|
||||
|
||||
// Light theme backgrounds
|
||||
light: {
|
||||
bg: "#FBF9F6",
|
||||
bgAlt: "#F5F1ED",
|
||||
surface: "#FFFFFF",
|
||||
sidebar: "#F0EFEC",
|
||||
border: "#E6E4DD",
|
||||
textMain: "#383733",
|
||||
textMuted: "#75736E",
|
||||
},
|
||||
|
||||
// Dark theme backgrounds
|
||||
dark: {
|
||||
bg: "#191918",
|
||||
bgAlt: "#1F1F1E",
|
||||
surface: "#242423",
|
||||
sidebar: "#1F1F1E",
|
||||
border: "#333331",
|
||||
textMain: "#ECEBE8",
|
||||
textMuted: "#9E9D99",
|
||||
},
|
||||
|
||||
// Status colors
|
||||
status: {
|
||||
success: "#22C55E",
|
||||
successLight: "#DCFCE7",
|
||||
successDark: "#166534",
|
||||
warning: "#F59E0B",
|
||||
warningLight: "#FEF3C7",
|
||||
warningDark: "#92400E",
|
||||
error: "#EF4444",
|
||||
errorLight: "#FEE2E2",
|
||||
errorDark: "#991B1B",
|
||||
info: "#3B82F6",
|
||||
infoLight: "#DBEAFE",
|
||||
infoDark: "#1E40AF",
|
||||
},
|
||||
};
|
||||
|
||||
// CSS Variables mapping for Tailwind
|
||||
export const CSS_VARIABLES = {
|
||||
light: {
|
||||
"--color-primary": COLORS.primary.DEFAULT,
|
||||
"--color-primary-hover": COLORS.primary.hover,
|
||||
"--color-bg": COLORS.light.bg,
|
||||
"--color-bg-alt": COLORS.light.bgAlt,
|
||||
"--color-surface": COLORS.light.surface,
|
||||
"--color-sidebar": COLORS.light.sidebar,
|
||||
"--color-border": COLORS.light.border,
|
||||
"--color-text-main": COLORS.light.textMain,
|
||||
"--color-text-muted": COLORS.light.textMuted,
|
||||
},
|
||||
dark: {
|
||||
"--color-primary": COLORS.primary.DEFAULT,
|
||||
"--color-primary-hover": COLORS.primary.hover,
|
||||
"--color-bg": COLORS.dark.bg,
|
||||
"--color-bg-alt": COLORS.dark.bgAlt,
|
||||
"--color-surface": COLORS.dark.surface,
|
||||
"--color-sidebar": COLORS.dark.sidebar,
|
||||
"--color-border": COLORS.dark.border,
|
||||
"--color-text-main": COLORS.dark.textMain,
|
||||
"--color-text-muted": COLORS.dark.textMuted,
|
||||
},
|
||||
};
|
||||
53
src/shared/constants/config.js
Normal file
53
src/shared/constants/config.js
Normal file
@@ -0,0 +1,53 @@
|
||||
// App configuration
|
||||
export const APP_CONFIG = {
|
||||
name: "Endpoint Proxy",
|
||||
description: "AI Infrastructure Management",
|
||||
version: "1.0.0",
|
||||
};
|
||||
|
||||
// Theme configuration
|
||||
export const THEME_CONFIG = {
|
||||
storageKey: "theme",
|
||||
defaultTheme: "system", // "light" | "dark" | "system"
|
||||
};
|
||||
|
||||
// Subscription
|
||||
export const SUBSCRIPTION_CONFIG = {
|
||||
price: 1.0,
|
||||
currency: "USD",
|
||||
interval: "month",
|
||||
planName: "Pro Plan",
|
||||
};
|
||||
|
||||
// API endpoints
|
||||
export const API_ENDPOINTS = {
|
||||
users: "/api/users",
|
||||
providers: "/api/providers",
|
||||
payments: "/api/payments",
|
||||
auth: "/api/auth",
|
||||
};
|
||||
|
||||
// Provider API endpoints (for display only)
|
||||
export const PROVIDER_ENDPOINTS = {
|
||||
openrouter: "https://openrouter.ai/api/v1/chat/completions",
|
||||
glm: "https://api.z.ai/api/anthropic/v1/messages",
|
||||
kimi: "https://api.kimi.com/coding/v1/messages",
|
||||
minimax: "https://api.minimax.io/anthropic/v1/messages",
|
||||
openai: "https://api.openai.com/v1/chat/completions",
|
||||
anthropic: "https://api.anthropic.com/v1/messages",
|
||||
gemini: "https://generativelanguage.googleapis.com/v1beta/models",
|
||||
};
|
||||
|
||||
// Re-export from providers.js for backward compatibility
|
||||
export {
|
||||
OAUTH_PROVIDERS,
|
||||
APIKEY_PROVIDERS,
|
||||
AI_PROVIDERS,
|
||||
AUTH_METHODS,
|
||||
} from "./providers.js";
|
||||
|
||||
// Re-export from models.js for backward compatibility
|
||||
export {
|
||||
PROVIDER_MODELS,
|
||||
AI_MODELS,
|
||||
} from "./models.js";
|
||||
4
src/shared/constants/index.js
Normal file
4
src/shared/constants/index.js
Normal file
@@ -0,0 +1,4 @@
|
||||
// Shared Constants - Export all
|
||||
export * from "./colors";
|
||||
export * from "./config";
|
||||
|
||||
34
src/shared/constants/models.js
Normal file
34
src/shared/constants/models.js
Normal file
@@ -0,0 +1,34 @@
|
||||
// Re-export from open-sse (single source of truth)
|
||||
export {
|
||||
PROVIDER_MODELS,
|
||||
getProviderModels,
|
||||
getDefaultModel,
|
||||
isValidModel as isValidModelCore,
|
||||
findModelName,
|
||||
getModelTargetFormat,
|
||||
PROVIDER_ID_TO_ALIAS,
|
||||
getModelsByProviderId
|
||||
} from "open-sse";
|
||||
|
||||
import { AI_PROVIDERS } from "./providers.js";
|
||||
import { PROVIDER_MODELS as MODELS } from "open-sse";
|
||||
|
||||
// Providers that accept any model (passthrough)
|
||||
const PASSTHROUGH_PROVIDERS = new Set(
|
||||
Object.entries(AI_PROVIDERS)
|
||||
.filter(([, p]) => p.passthroughModels)
|
||||
.map(([key]) => key)
|
||||
);
|
||||
|
||||
// Wrap isValidModel with passthrough providers
|
||||
export function isValidModel(aliasOrId, modelId) {
|
||||
if (PASSTHROUGH_PROVIDERS.has(aliasOrId)) return true;
|
||||
const models = MODELS[aliasOrId];
|
||||
if (!models) return false;
|
||||
return models.some(m => m.id === modelId);
|
||||
}
|
||||
|
||||
// Legacy AI_MODELS for backward compatibility
|
||||
export const AI_MODELS = Object.entries(MODELS).flatMap(([alias, models]) =>
|
||||
models.map(m => ({ provider: alias, model: m.id, name: m.name }))
|
||||
);
|
||||
65
src/shared/constants/providers.js
Normal file
65
src/shared/constants/providers.js
Normal file
@@ -0,0 +1,65 @@
|
||||
// Provider definitions
|
||||
|
||||
// OAuth Providers
|
||||
export const OAUTH_PROVIDERS = {
|
||||
claude: { id: "claude", alias: "cc", name: "Claude Code", icon: "smart_toy", color: "#D97757" },
|
||||
antigravity: { id: "antigravity", alias: "ag", name: "Antigravity", icon: "rocket_launch", color: "#F59E0B" },
|
||||
codex: { id: "codex", alias: "cx", name: "OpenAI Codex", icon: "code", color: "#3B82F6" },
|
||||
iflow: { id: "iflow", alias: "if", name: "iFlow AI", icon: "water_drop", color: "#6366F1" },
|
||||
qwen: { id: "qwen", alias: "qw", name: "Qwen Code", icon: "psychology", color: "#10B981" },
|
||||
"gemini-cli": { id: "gemini-cli", alias: "gc", name: "Gemini CLI", icon: "terminal", color: "#4285F4" },
|
||||
github: { id: "github", alias: "gh", name: "GitHub Copilot", icon: "code", color: "#333333" },
|
||||
};
|
||||
|
||||
export const APIKEY_PROVIDERS = {
|
||||
openrouter: { id: "openrouter", alias: "openrouter", name: "OpenRouter", icon: "router", color: "#6366F1", textIcon: "OR" , passthroughModels: true },
|
||||
glm: { id: "glm", alias: "glm", name: "GLM Coding", icon: "code", color: "#2563EB", textIcon: "GL" },
|
||||
kimi: { id: "kimi", alias: "kimi", name: "Kimi Coding", icon: "psychology", color: "#1E3A8A", textIcon: "KM" },
|
||||
minimax: { id: "minimax", alias: "minimax", name: "Minimax Coding", icon: "memory", color: "#7C3AED", textIcon: "MM" },
|
||||
openai: { id: "openai", alias: "openai", name: "OpenAI", icon: "auto_awesome", color: "#10A37F", textIcon: "OA" },
|
||||
anthropic: { id: "anthropic", alias: "anthropic", name: "Anthropic", icon: "smart_toy", color: "#D97757", textIcon: "AN" },
|
||||
gemini: { id: "gemini", alias: "gemini", name: "Gemini", icon: "diamond", color: "#4285F4", textIcon: "GE" },
|
||||
};
|
||||
|
||||
// All providers (combined)
|
||||
export const AI_PROVIDERS = { ...OAUTH_PROVIDERS, ...APIKEY_PROVIDERS };
|
||||
|
||||
// Auth methods
|
||||
export const AUTH_METHODS = {
|
||||
oauth: { id: "oauth", name: "OAuth", icon: "lock" },
|
||||
apikey: { id: "apikey", name: "API Key", icon: "key" },
|
||||
};
|
||||
|
||||
// Helper: Get provider by alias
|
||||
export function getProviderByAlias(alias) {
|
||||
for (const provider of Object.values(AI_PROVIDERS)) {
|
||||
if (provider.alias === alias || provider.id === alias) {
|
||||
return provider;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Helper: Get provider ID from alias
|
||||
export function resolveProviderId(aliasOrId) {
|
||||
const provider = getProviderByAlias(aliasOrId);
|
||||
return provider?.id || aliasOrId;
|
||||
}
|
||||
|
||||
// Helper: Get alias from provider ID
|
||||
export function getProviderAlias(providerId) {
|
||||
const provider = AI_PROVIDERS[providerId];
|
||||
return provider?.alias || providerId;
|
||||
}
|
||||
|
||||
// Alias to ID mapping (for quick lookup)
|
||||
export const ALIAS_TO_ID = Object.values(AI_PROVIDERS).reduce((acc, p) => {
|
||||
acc[p.alias] = p.id;
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
// ID to Alias mapping
|
||||
export const ID_TO_ALIAS = Object.values(AI_PROVIDERS).reduce((acc, p) => {
|
||||
acc[p.id] = p.alias;
|
||||
return acc;
|
||||
}, {});
|
||||
Reference in New Issue
Block a user