Files
zclaw_openfang/desktop/src/constants/api-urls.ts
iven db1f8dcbbc
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
feat(desktop): Gateway URL 配置化 + Rust panic hook 崩溃报告
- api-urls.ts: GATEWAY_URLS 读 VITE_GATEWAY_HTTP/WS env
- gateway-storage.ts: DEFAULT_GATEWAY_URL 读 VITE_GATEWAY_WS env
- lib.rs: 添加 tracing_subscriber 初始化 + panic::set_hook
  崩溃时自动写入 crash-reports/ 目录供诊断
- Cargo.toml: 添加 tracing-subscriber workspace 依赖
2026-04-11 02:54:23 +08:00

82 lines
2.1 KiB
TypeScript

/**
* API URL Constants - Single Source of Truth
*
* All API URLs should reference this file.
* Backend (Rust) should use the same values in config.rs
*/
// === LLM Provider URLs ===
/**
* LLM Provider API URLs
*/
export const LLM_PROVIDER_URLS = {
// OpenAI
OPENAI: 'https://api.openai.com/v1',
// Anthropic
ANTHROPIC: 'https://api.anthropic.com',
// Gemini
GEMINI: 'https://generativelanguage.googleapis.com/v1beta',
// DeepSeek
DEEPSEEK: 'https://api.deepseek.com/v1',
// 智谱 (Zhipu)
ZHIPU: 'https://open.bigmodel.cn/api/paas/v4',
ZHIPU_CODING: 'https://open.bigmodel.cn/api/coding/paas/v4',
// Kimi (Moonshot)
KIMI: 'https://api.moonshot.cn/v1',
KIMI_CODING: 'https://api.kimi.com/coding/v1',
// 百炼 (Qwen/Bailian)
QWEN: 'https://dashscope.aliyuncs.com/compatible-mode/v1',
QWEN_CODING: 'https://coding.dashscope.aliyuncs.com/v1',
// 火山引擎 (Volcengine/Doubao)
VOLCENGINE: 'https://ark.cn-beijing.volces.com/api/v3',
// Local/OLLama
OLLAMA: 'http://localhost:11434/v1',
LM_STUDIO: 'http://localhost:1234/v1',
VLLM: 'http://localhost:8000/v1',
} as const;
// === ZCLAW Gateway URLs ===
/**
* ZCLAW Gateway default URLs
*/
export const GATEWAY_URLS = {
DEFAULT_HTTP: import.meta.env.VITE_GATEWAY_HTTP || 'http://127.0.0.1:50051',
DEFAULT_WS: import.meta.env.VITE_GATEWAY_WS || 'ws://127.0.0.1:50051/ws',
FALLBACK_HTTP: 'http://127.0.0.1:4200',
FALLBACK_WS: 'ws://127.0.0.1:4200/ws',
} as const;
// === Helper Functions ===
/**
* Get provider URL by name
*/
export function getProviderUrl(provider: string): string {
const key = provider.toUpperCase().replace(/-/g, '_') as keyof typeof LLM_PROVIDER_URLS;
return LLM_PROVIDER_URLS[key] || LLM_PROVIDER_URLS.OPENAI;
}
/**
* Check if URL is a coding plan endpoint
*/
export function isCodingUrl(url: string): boolean {
return url.includes('/coding/') || url.includes('-coding');
}
/**
* Check if URL is a local endpoint
*/
export function isLocalUrl(url: string): boolean {
return url.includes('localhost') || url.includes('127.0.0.1') || url.includes('[::1]');
}