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
|
|
|
/**
|
2026-03-01 06:40:55 -05:00
|
|
|
* Detect source format from request URL pathname + body.
|
|
|
|
|
* Returns null to fall back to body-based detection.
|
2026-03-01 03:35:41 -05:00
|
|
|
*/
|
2026-03-01 06:40:55 -05:00
|
|
|
export function detectFormatByEndpoint(pathname, body) {
|
|
|
|
|
// /v1/responses is always openai-responses
|
|
|
|
|
if (pathname.includes("/v1/responses")) return FORMATS.OPENAI_RESPONSES;
|
|
|
|
|
|
|
|
|
|
// /v1/chat/completions + input[] → treat as openai (Cursor CLI sends Responses body via chat endpoint)
|
|
|
|
|
if (pathname.includes("/v1/chat/completions") && Array.isArray(body?.input)) {
|
|
|
|
|
return FORMATS.OPENAI;
|
2026-03-01 03:35:41 -05:00
|
|
|
}
|
2026-03-01 06:40:55 -05:00
|
|
|
|
2026-03-01 03:35:41 -05:00
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|