Fix : Codex on cursor
This commit is contained in:
@@ -12,3 +12,20 @@ export const FORMATS = {
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -143,6 +143,9 @@ export function openaiResponsesToOpenAIRequest(model, body, stream, credentials)
|
||||
* Convert OpenAI Chat Completions to OpenAI Responses API format
|
||||
*/
|
||||
export function openaiToOpenAIResponsesRequest(model, body, stream, credentials) {
|
||||
// Body already in Responses API format (e.g. Cursor CLI calling /chat/completions with input[])
|
||||
if (body.input) return { ...body, model, stream: true };
|
||||
|
||||
const result = {
|
||||
model,
|
||||
input: [],
|
||||
|
||||
Reference in New Issue
Block a user