Files
9router/open-sse/translator/schema/blocks.js
nguyenha935 d06e0d26c6 fix(translator): preserve Responses Lite tools across Chat providers
Codex Responses Lite clients routed to a chat-native OpenAI-compatible
provider lost tool use in three places: non-streaming Chat responses
leaked the raw chat.completion envelope instead of Responses output
items, internal reasoning continuity fields leaked into the outbound
Chat body causing some upstreams to reject the request, and the
Responses to Chat request translator ignored additional_tools,
custom_tool_call, and custom_tool_call_output items entirely.

Also fixes apiType (chat vs responses) for openai-compatible nodes
being resolved from the immutable provider ID instead of the stored
node config, so editing a node's API Type had no runtime effect.
2026-08-05 13:27:25 +07:00

47 lines
1.4 KiB
JavaScript

// Content-block "type" discriminators — fixed per format. Pure data (no logic).
// OpenAI chat content blocks + tool_call wrapper.
export const OPENAI_BLOCK = {
TEXT: "text",
IMAGE_URL: "image_url",
IMAGE: "image",
INPUT_AUDIO: "input_audio",
AUDIO_URL: "audio_url",
FILE: "file",
FUNCTION: "function",
};
// Claude content blocks.
export const CLAUDE_BLOCK = {
TEXT: "text",
IMAGE: "image",
DOCUMENT: "document",
TOOL_USE: "tool_use",
TOOL_RESULT: "tool_result",
THINKING: "thinking",
REDACTED_THINKING: "redacted_thinking",
};
// OpenAI Responses API item types.
export const RESPONSES_ITEM = {
MESSAGE: "message",
FUNCTION_CALL: "function_call",
FUNCTION_CALL_OUTPUT: "function_call_output",
CUSTOM_TOOL_CALL: "custom_tool_call",
CUSTOM_TOOL_CALL_OUTPUT: "custom_tool_call_output",
ADDITIONAL_TOOLS: "additional_tools",
REASONING: "reasoning",
OUTPUT_TEXT: "output_text",
INPUT_TEXT: "input_text",
INPUT_IMAGE: "input_image",
SUMMARY_TEXT: "summary_text",
};
// Valid OpenAI block types (used by filterToOpenAIFormat).
export const VALID_OPENAI_CONTENT_TYPES = [
OPENAI_BLOCK.TEXT, OPENAI_BLOCK.IMAGE_URL, OPENAI_BLOCK.IMAGE, OPENAI_BLOCK.INPUT_AUDIO, OPENAI_BLOCK.AUDIO_URL, OPENAI_BLOCK.FILE,
];
export const VALID_OPENAI_MESSAGE_TYPES = [
OPENAI_BLOCK.TEXT, OPENAI_BLOCK.IMAGE_URL, OPENAI_BLOCK.IMAGE, "tool_calls", CLAUDE_BLOCK.TOOL_RESULT,
];