fix(translator): shape Anthropic non-stream responses from forced-streaming providers
The non-streaming Anthropic path leaked OpenAI chat.completion bodies to Claude clients when the upstream provider forces streaming (forced SSE->JSON path): parseSSEToOpenAIResponse yields choices[] which Claude Code cannot parse. Convert to Claude Messages shape for sourceFormat CLAUDE in sseToJsonHandler. Shared toClaudeMessageShape/openAICompletionToClaudeMessage moved to translator/concerns/claudeShape.js to avoid circular import between nonStreamingHandler and sseToJsonHandler. 5 new tests: sse-to-json reassembly + Claude guard, plus existing anthropic-nonstream-shape updated to import from the concern.
This commit is contained in:
1 parent
b239b2a8a9
commit
3de32a10f3
5 files changed
+139
-67
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const { stripEosSentinel } = await import("../../open-sse/translator/concerns/eosStrip.js");
|
||||
const { toClaudeMessageShape } = await import("../../open-sse/handlers/chatCore/nonStreamingHandler.js");
|
||||
const { toClaudeMessageShape } = await import("../../open-sse/translator/concerns/claudeShape.js");
|
||||
|
||||
// An OpenAI-shape body as returned by a claude-transport executor (opencode/
|
||||
// big-pickle): no type:"message", choices[] present. This is what an Anthropic
|
||||
|
||||
Reference in new issue
Block a user