mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
32 lines
808 B
JavaScript
32 lines
808 B
JavaScript
// Format identifiers
|
|
export const FORMATS = {
|
|
OPENAI: "openai",
|
|
OPENAI_RESPONSES: "openai-responses",
|
|
OPENAI_RESPONSE: "openai-response",
|
|
CLAUDE: "claude",
|
|
GEMINI: "gemini",
|
|
GEMINI_CLI: "gemini-cli",
|
|
CODEX: "codex",
|
|
ANTIGRAVITY: "antigravity",
|
|
KIRO: "kiro",
|
|
CURSOR: "cursor"
|
|
};
|
|
|
|
// Map endpoint suffix → source format (takes priority over body-based detection)
|
|
const ENDPOINT_FORMAT_MAP = {
|
|
"/v1/responses": FORMATS.OPENAI_RESPONSES,
|
|
"/v1/chat/completions": FORMATS.OPENAI,
|
|
};
|
|
|
|
/**
|
|
* Detect source format from request URL pathname.
|
|
* Returns null if no matching endpoint found.
|
|
*/
|
|
export function detectFormatByEndpoint(pathname) {
|
|
for (const [segment, format] of Object.entries(ENDPOINT_FORMAT_MAP)) {
|
|
if (pathname.includes(segment)) return format;
|
|
}
|
|
return null;
|
|
}
|
|
|