| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
… helpers Fix concurrency bug: module-level toolCallIndex and _messageId were shared across concurrent requests. Replace toOpenAIStreamChunk / toOpenAIErrorChunk with a per-request OpenAIStreamEncoder class. Remove getMessageId/resetMessageId globals from util.ts. Extract applyNoToolsSafeguard for reuse by the upcoming Anthropic translator. Deduplicate OPENAI_FINISH_MAP (was declared twice).
Add full Anthropic API surface alongside the existing OpenAI-compatible endpoint: - POST /v1/messages (streaming + non-streaming) - POST /v1/messages/count_tokens (CJK-weighted heuristic estimate) - GET /v1/models (content-negotiated via anthropic-version header) Translator (src/translate/anthropic.ts): - toCCRequest: Anthropic → CC request (messages, tools, tool_choice, thinking, system, images, tool_result with name lookup) - AnthropicStreamEncoder: CC events → Anthropic SSE (message_start, content_block_*, signature_delta, ping, message_delta, message_stop, error) - buildAnthropicResponse: non-streaming Anthropic response assembly Supporting modules: - anthropic-types.ts: discriminated-union types (no any) - anthropic-models.ts: env-based claude-* → CC model mapping - validation.ts: validateAnthropicRequest (rejects unsupported blocks/tools) - stream.ts: formatAnthropicSSE for event-typed SSE - server.ts: handleMessages, handleCountTokens, sendAnthropicError, format-aware handleUpstreamError(err, format) 122 tests pass, lint clean, build clean.
- /v1/messages (non-streaming + streaming) - /v1/messages/count_tokens - /v1/models content-negotiation (Anthropic vs OpenAI shape) - Anthropic error shapes (400 invalid_request_error)
Instead of printing instructions, detect shell (zsh/bash/fish) and append ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY=proxy-managed to the user's RC file. Detect already-set vars to avoid duplicates.
- Write model config to ~/.config/commandcode-api-proxy/anthropic-models.json - Write Claude Code settings to ~/.config/commandcode-api-proxy/claude-settings.json (does NOT touch ~/.claude/settings.json) - Print usage: claude --settings <path> or alias shortcut
- Remove anthropic-models.json glob config (no longer needed) - --setup-claude-code only writes claude-settings.json with model env vars (ANTHROPIC_DEFAULT_SONNET/OPUS/HAIKU_MODEL) - resolveAnthropicModel uses ANTHROPIC_DEFAULT_MODEL env or fallback - Proxy pass-through model ID, Claude Code maps via its settings
| Back | FazBrowse Home | New Git URL |
Summary
Add full Anthropic Messages API surface alongside the existing OpenAI-compatible endpoint. Claude Code can now use the proxy via claude --settings ~/.config/commandcode-api-proxy/claude-settings.json.
Changes
Phase 1: Refactor
Phase 2: Anthropic API
Setup
Tests
Usage
npx commandcode-api-proxy --setup-claude-code claude --settings ~/.config/commandcode-api-proxy/claude-settings.json