All files / src/constants api-urls.ts

0% Statements 0/32
100% Branches 1/1
100% Functions 1/1
0% Lines 0/32

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82                                                                                                                                                                   
/**
 * 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: 'http://127.0.0.1:50051',
  DEFAULT_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]');
}