Files
hzhang 94f33a003a feat: initial extract of shared anthropic-compat client + translator
Extracted from Plexum-minimax-provider and Plexum-kimi-provider (both
had near-identical copies under internal/anthropic + internal/translate).
Future provider plugins (Qwen, Doubao, …) import these two packages
instead of re-implementing the protocol.

anthropic/ (~220 LOC + 6 tests):
- minimal HTTP+SSE Anthropic Messages client (POST /v1/messages,
  stream:true, parses event:/data: SSE)
- Client.UserAgent + Client.ExtraHeaders fields for per-backend
  customization (Kimi needs "claude-code/0.1.0"; MiniMax is flexible)
- non-2xx surfaces as Go error; mid-stream errors as final
  Event{Type:"error"}

translate/ (~220 LOC):
- CanonicalToAnthropic: TurnRequest → MessagesRequest
- blockToAnthropic: TextBlock / ToolUseBlock / ToolResultBlock /
  ThinkingBlock → loose ContentBlock map; preserves signatures
- Translator: per-turn state machine; anthropic.Event stream →
  canonical.TurnEvent stream (text + thinking + tool_use deltas;
  signature_delta capture; message_delta stop_reason + usage)

Both MiniMax and Kimi now import from here; their internal/* dirs are
gone. Live verified after refactor — both still answer "ready" via
plexum say.
2026-05-31 20:34:57 +01:00

203 B