History

Merge branch 'router-for-me:main' into main

Luis Pater committed 8 months agov6.8.23-0

Commit 57d18bb2 parents 10b9c6c 7b0eb413 files · +37 −3Browse files

Unified · Split

3 files
  1. internal/auth/claude/anthropic_auth.go +1 −1
  2. internal/registry/model_definitions_static_data.go +15 −0
  3. internal/translator/codex/claude/codex_claude_response.go +21 −2
internal/auth/claude/anthropic_auth.go+1−1
@@ -20,7 +20,7 @@ import ( · 19 unmodified lines
2020 // OAuth configuration constants for Claude/Anthropic
2121 const (
2222 AuthURL = "https://claude.ai/oauth/authorize"
23− TokenURL = "https://console.anthropic.com/v1/oauth/token"
23+ TokenURL = "https://api.anthropic.com/v1/oauth/token"
2424 ClientID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e"
2525 RedirectURI = "http://localhost:54545/callback"
2626 )
internal/registry/model_definitions_static_data.go+15−0
@@ -306,6 +306,21 @@ func GetGeminiVertexModels() []*ModelInfo { · 305 unmodified lines
306306 SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
307307 Thinking: &ThinkingSupport{Min: 128, Max: 32768, ZeroAllowed: false, DynamicAllowed: true, Levels: []string{"minimal", "low", "medium", "high"}},
308308 },
309+ {
310+ ID: "gemini-3.1-pro-preview",
311+ Object: "model",
312+ Created: 1771491385,
313+ OwnedBy: "google",
314+ Type: "gemini",
315+ Name: "models/gemini-3.1-pro-preview",
316+ Version: "3.1",
317+ DisplayName: "Gemini 3.1 Pro Preview",
318+ Description: "Gemini 3.1 Pro Preview",
319+ InputTokenLimit: 1048576,
320+ OutputTokenLimit: 65536,
321+ SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
322+ Thinking: &ThinkingSupport{Min: 1, Max: 32768, ZeroAllowed: false, DynamicAllowed: true, Levels: []string{"low", "high"}},
323+ },
309324 {
310325 ID: "gemini-3-pro-image-preview",
311326 Object: "model",
internal/translator/codex/claude/codex_claude_response.go+21−2
@@ -22,8 +22,9 @@ var ( · 21 unmodified lines
2222
2323 // ConvertCodexResponseToClaudeParams holds parameters for response conversion.
2424 type ConvertCodexResponseToClaudeParams struct {
25− HasToolCall bool
26− BlockIndex int
25+ HasToolCall bool
26+ BlockIndex int
27+ HasReceivedArgumentsDelta bool
2728 }
2829
2930 // ConvertCodexResponseToClaude performs sophisticated streaming response format conversion.
@@ -137,6 +138,7 @@ func ConvertCodexResponseToClaude(_ context.Context, _ string, originalRequestRa · 107 unmodified lines
137138 itemType := itemResult.Get("type").String()
138139 if itemType == "function_call" {
139140 (*param).(*ConvertCodexResponseToClaudeParams).HasToolCall = true
141+ (*param).(*ConvertCodexResponseToClaudeParams).HasReceivedArgumentsDelta = false
140142 template = `{"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"","name":"","input":{}}}`
141143 template, _ = sjson.Set(template, "index", (*param).(*ConvertCodexResponseToClaudeParams).BlockIndex)
142144 template, _ = sjson.Set(template, "content_block.id", itemResult.Get("call_id").String())
@@ -171,12 +173,29 @@ func ConvertCodexResponseToClaude(_ context.Context, _ string, originalRequestRa · 28 unmodified lines
171173 output += fmt.Sprintf("data: %s\n\n", template)
172174 }
173175 } else if typeStr == "response.function_call_arguments.delta" {
176+ (*param).(*ConvertCodexResponseToClaudeParams).HasReceivedArgumentsDelta = true
174177 template = `{"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""}}`
175178 template, _ = sjson.Set(template, "index", (*param).(*ConvertCodexResponseToClaudeParams).BlockIndex)
176179 template, _ = sjson.Set(template, "delta.partial_json", rootResult.Get("delta").String())
177180
178181 output += "event: content_block_delta\n"
179182 output += fmt.Sprintf("data: %s\n\n", template)
183+ } else if typeStr == "response.function_call_arguments.done" {
184+ // Some models (e.g. gpt-5.3-codex-spark) send function call arguments
185+ // in a single "done" event without preceding "delta" events.
186+ // Emit the full arguments as a single input_json_delta so the
187+ // downstream Claude client receives the complete tool input.
188+ // When delta events were already received, skip to avoid duplicating arguments.
189+ if !(*param).(*ConvertCodexResponseToClaudeParams).HasReceivedArgumentsDelta {
190+ if args := rootResult.Get("arguments").String(); args != "" {
191+ template = `{"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":""}}`
192+ template, _ = sjson.Set(template, "index", (*param).(*ConvertCodexResponseToClaudeParams).BlockIndex)
193+ template, _ = sjson.Set(template, "delta.partial_json", args)
194+
195+ output += "event: content_block_delta\n"
196+ output += fmt.Sprintf("data: %s\n\n", template)
197+ }
198+ }
180199 }
181200
182201 return []string{output}