diff --git a/open-sse/config/providerRegistry.ts b/open-sse/config/providerRegistry.ts index 6e76c4da8cc2..100c5ccb18cf 100644 --- a/open-sse/config/providerRegistry.ts +++ b/open-sse/config/providerRegistry.ts @@ -3049,7 +3049,7 @@ const _REGISTRY_EAGER: Record = { "claude-web": { id: "claude-web", - alias: "claude-web", + alias: "cw", format: "openai", executor: "claude-web", baseUrl: "https://claude.ai/api/organizations", diff --git a/src/lib/providers/wrappers/claudeWeb.ts b/src/lib/providers/wrappers/claudeWeb.ts deleted file mode 100644 index 4aea8258445c..000000000000 --- a/src/lib/providers/wrappers/claudeWeb.ts +++ /dev/null @@ -1,137 +0,0 @@ -import { normalizeSessionCookieHeader, extractCookieValue } from "../webCookieAuth"; - -/** - * Claude Web Provider Types - * Based on real Claude Web API structure captured from browser Network tab - * - * Real API Endpoint: - * POST https://claude.ai/api/organizations/{orgId}/chat_conversations/{convId}/completion - * - * Authentication: - * - Cookie header with sessionKey and other session cookies - * - anthropic-device-id header (UUID) - * - anthropic-client-platform: web_claude_ai - * - Cloudflare cookies (cf_clearance, __cf_bm, _cfuvid) - */ - -export interface ClaudeWebConfig { - cookie: string; - deviceId?: string; - orgId?: string; - conversationId?: string; - model?: string; -} - -/** - * Full request payload matching real Claude Web API format - */ -export interface ClaudeWebRequest { - prompt: string; - model: string; - timezone: string; - personalized_styles: Array<{ - type: string; - key: string; - name: string; - nameKey: string; - prompt: string; - summary: string; - summaryKey: string; - isDefault: boolean; - }>; - locale: string; - tools: Array<{ - name?: string; - description?: string; - input_schema?: Record; - integration_name?: string; - is_mcp_app?: boolean; - type?: string; - }>; - turn_message_uuids: { - human_message_uuid: string; - assistant_message_uuid: string; - }; - attachments: unknown[]; - files: unknown[]; - sync_sources: unknown[]; - rendering_mode: string; - create_conversation_params: { - name: string; - model: string; - include_conversation_preferences: boolean; - paprika_mode: unknown; - compass_mode: unknown; - is_temporary: boolean; - enabled_imagine: boolean; - }; -} - -export interface ClaudeWebResponse { - completion?: string; - stop_reason?: string; - model?: string; - delta?: { - type?: string; - text?: string; - }; - [key: string]: unknown; -} - -export interface ClaudeWebStreamingChunk { - type?: string; - completion?: string; - stop_reason?: string | null; - model?: string; - delta?: { - type?: string; - text?: string; - }; - [key: string]: unknown; -} - -/** - * Utility to resolve the cookie for Claude Web - * Claude web primarily uses 'sessionKey' cookie for authentication - */ -export function resolveClaudeWebCookie(rawValue: string): string { - const cookieName = "sessionKey"; - // If the value is just the cookie value, normalize it - // If it's a blob, extract the specific cookie - return normalizeSessionCookieHeader(rawValue, cookieName); -} - -export function getClaudeWebToken(rawValue: string): string { - return extractCookieValue(rawValue, "sessionKey"); -} - -/** - * API info for Claude Web completion endpoint - * - * Notes: - * - Requires cf_clearance cookie from Cloudflare Turnstile - * - Organization ID obtained from /api/organizations endpoint - * - Conversation ID can be new UUID or existing conversation - * - Device ID should be persisted across sessions - */ -export const CLAUDE_WEB_API_INFO = { - baseUrl: "https://claude.ai/api", - // Dynamic endpoint: /organizations/{orgId}/chat_conversations/{convId}/completion - chatPathTemplate: "/organizations/:orgId/chat_conversations/:convId/completion", - organizationsPath: "/organizations", - sessionPath: "/auth/session", - apiKeyHeader: "Cookie", - requiredHeaders: { - "anthropic-client-platform": "web_claude_ai", - "anthropic-device-id": "{deviceId}", - Referer: "https://claude.ai/new", - Accept: "text/event-stream", - }, - requiredCookies: [ - "sessionKey", // Main authentication - "routingHint", // Anthropic routing - "__cf_bm", // Cloudflare bot management - "_cfuvid", // Cloudflare visitor ID - "cf_clearance", // Cloudflare Turnstile clearance (REQUIRED) - ], -} as const; diff --git a/src/lib/providers/wrappers/deepseekWeb.ts b/src/lib/providers/wrappers/deepseekWeb.ts deleted file mode 100644 index 0ded40b00042..000000000000 --- a/src/lib/providers/wrappers/deepseekWeb.ts +++ /dev/null @@ -1,93 +0,0 @@ -export interface DeepSeekWebConfig { - cookies?: string; - userAgent?: string; - sessionRefreshInterval?: number; - autoRefresh?: boolean; -} - -export interface DeepSeekWebMessage { - role: "user" | "assistant" | "system"; - content: string; -} - -export interface DeepSeekWebCompletionRequest { - model: "deepseek-v4-flash" | "deepseek-v4-pro" | "deepseek-r1" | "deepseek-v3" | string; - messages: DeepSeekWebMessage[]; - stream?: boolean; - temperature?: number; - max_tokens?: number; - reasoning_effort?: "low" | "medium" | "high"; - top_p?: number; - frequency_penalty?: number; - presence_penalty?: number; -} - -export interface DeepSeekWebCompletionResponse { - id: string; - object: string; - created: number; - model: string; - choices: Array<{ - index: number; - message?: { role: string; content: string }; - delta?: { content?: string; role?: string }; - finish_reason: string | null; - }>; - usage?: { - prompt_tokens: number; - completion_tokens: number; - total_tokens: number; - }; -} - -export interface DeepSeekWebStreamingChunk { - id?: string; - object?: string; - created?: number; - model?: string; - choices?: Array<{ - index?: number; - delta?: { content?: string; role?: string }; - finish_reason?: string | null; - }>; - [key: string]: unknown; -} - -export const DeepSeekWebEndpoint = { - base: "https://chat.deepseek.com", - completion: "/api/v0/chat/completion", - rateLimit: { requestsPerMinute: 60, tokensPerDay: 100000, concurrentRequests: 10 }, -}; - -export const DeepSeekWebModels = { - default: "deepseek-v4-flash", - flash: "deepseek-v4-flash", - pro: "deepseek-v4-pro", - reasoning: "deepseek-r1", - v3: "deepseek-v3", -} as const; - -export const DeepSeekWebDefaults = { - temperature: 0.7, - maxTokens: 4096, - reasoningEffort: "medium" as const, - topP: 1.0, - frequencyPenalty: 0, - presencePenalty: 0, -}; - -export const DeepSeekWebHeaders = { - "Content-Type": "application/json", - "User-Agent": - "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36", - Accept: "text/event-stream,application/json", - "Accept-Encoding": "gzip, deflate, br", -}; - -export const DeepSeekWebErrors = { - SESSION_EXPIRED: "session_expired", - RATE_LIMITED: "rate_limit_exceeded", - INVALID_REQUEST: "invalid_request_error", - SERVER_ERROR: "internal_server_error", - SERVICE_UNAVAILABLE: "service_unavailable", -};