| |
| |
| |
| |
|
|
| |
| const NATIVE_PAIRS = { |
| "claude": ["claude", "anthropic"], |
| "gemini-cli": ["gemini-cli"], |
| "antigravity": ["antigravity"], |
| "codex": ["codex"], |
| }; |
|
|
| |
| |
| |
| |
| |
| |
| export function detectClientTool(headers = {}, body = {}) { |
| const ua = (headers["user-agent"] || "").toLowerCase(); |
| const xApp = (headers["x-app"] || "").toLowerCase(); |
| const openaiIntent = (headers["openai-intent"] || "").toLowerCase(); |
| const initiator = (headers["x-initiator"] || headers["X-Initiator"] || "").toLowerCase(); |
|
|
| |
| if (body.userAgent === "antigravity") return "antigravity"; |
|
|
| |
| if (ua.includes("githubcopilotchat") || openaiIntent === "conversation-panel" || initiator === "user") { |
| return "github-copilot"; |
| } |
|
|
| |
| if (ua.includes("claude-cli") || ua.includes("claude-code") || xApp === "cli") return "claude"; |
|
|
| |
| if (ua.includes("gemini-cli")) return "gemini-cli"; |
|
|
| |
| if (ua.includes("codex-cli")) return "codex"; |
|
|
| |
| if (ua.includes("deepseek-tui")) return "deepseek-tui"; |
|
|
| return null; |
| } |
|
|
| |
| |
| |
| |
| |
| export function isNativePassthrough(clientTool, provider) { |
| if (!clientTool) return false; |
| const nativeProviders = NATIVE_PAIRS[clientTool]; |
| if (!nativeProviders) return false; |
| |
| const normalizedProvider = provider.startsWith("anthropic-compatible") |
| ? "anthropic" |
| : provider; |
| return nativeProviders.includes(normalizedProvider); |
| } |
|
|