Commit graph

12 commits

Author SHA1 Message Date
Franz Kafka
cea246da83 Implement remaining code review suggestions
- Add graceful shutdown with SIGTERM/SIGINT handling\n- Make model list configurable via config.yaml\n- Remove sensitive data from debug logs (log sizes instead of full bodies)\n- Handle array format in system messages (both string and []interface{})\n- Update config.yaml with new models structure
2026-04-15 09:16:44 +00:00
Franz Kafka
f65ad6b189 Improve code quality: remove unused code, simplify random, dynamic timestamps
- Remove unused buildToolCalls() function (logic is inlined)\n- Simplify randomString() using global rand (Go 1.20+)\n- Use dynamic timestamps instead of hardcoded 1234567890\n- Add time import to converter.go
2026-04-15 09:14:45 +00:00
Franz Kafka
1c2f59c53e Fix critical issues: panic risk and body size limits
- Add type assertion check for session ID context value to prevent panic\n- Add 10MB request body size limit to prevent memory exhaustion\n- Return 413 (Request Entity Too Large) for oversized requests\n- Add maxBodySize constant for easy adjustment
2026-04-15 09:11:50 +00:00
Franz Kafka
1c3eccce10 Use shared HTTP client for upstream requests
- Create package-level httpClient with 300s timeout\n- Reuse client instead of creating new one per request\n- Prevents resource exhaustion under load\n- Reduces connection overhead
2026-04-15 09:02:17 +00:00
73efb02461 fix: use non-streaming upstream requests, convert to SSE for clients 2026-04-15 08:38:54 +00:00
35878c0a92 debug: log request body 2026-04-15 08:21:24 +00:00
4d2ccfdaaa fix: add claude-code-20250219 beta header to match claude-code 2026-04-15 08:19:08 +00:00
8e282db13a debug: log raw upstream events 2026-04-15 08:05:30 +00:00
42118d803e fix: add missing log import 2026-04-15 07:59:48 +00:00
02989e59b5 fix: always stream from upstream, accumulate for non-streaming clients 2026-04-15 07:55:26 +00:00
Franz Kafka
f284f8dbde Add explicit blocked headers list for security
- Define blockedHeaders map for headers that should never be forwarded
- Include Referer, Cookie, X-Forwarded-* headers
- Prevents leaking internal URLs, session data, and client IPs to upstream
- Defensive measure even though no headers are currently copied
2026-04-15 06:48:37 +00:00
Franz Kafka
8450d96e2e Implement OpenAI-to-Anthropic proxy with streaming support
- Add request/response converters (OpenAI <-> Anthropic formats)
- Implement SSE streaming conversion (Anthropic events -> OpenAI SSE)
- Add /v1/models endpoint with Claude model list
- Add /v1/chat/completions endpoint with streaming and non-streaming support
- Fix context key type matching bug (sessionIDKey)
- Configurable upstream URL via config.yaml
- Mimic claude-code CLI headers for upstream requests
2026-04-15 06:29:03 +00:00