2026-01-04 22:37:09 -05:00
|
|
|
// 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",
|
2026-01-15 06:29:47 -05:00
|
|
|
ANTIGRAVITY: "antigravity",
|
2026-02-04 23:06:20 -05:00
|
|
|
KIRO: "kiro",
|
|
|
|
|
CURSOR: "cursor"
|
2026-01-04 22:37:09 -05:00
|
|
|
};
|
|
|
|
|
|
2026-03-01 03:35:41 -05:00
|
|
|
// 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;
|
|
|
|
|
}
|
|
|
|
|
|