[pull] master from MAXeaglet:master - #2
Open
pull[bot] wants to merge 7 commits into
Open
Conversation
getApiKey only read the Authorization: Bearer header, which the Anthropic TypeScript/JS SDK does not send — it authenticates via the x-api-key header. Fall back to x-api-key (case-insensitive) when no Bearer token is present, extracting the user_ key with the same regex. OpenAI-style requests keep working unchanged.
In handleChatCompletions, startTime/bytesReceived/lastCcEvent/keepaliveCount
were declared with const/let inside the try block after the await
forwardToCC() call, but the res.on('close') callback (registered later)
references them. If the client disconnects while the upstream response is
slow, the close callback runs before those declarations execute, hitting
the temporal dead zone and throwing ReferenceError. The non-stream idle
timeout catch branch has the same risk.
Hoist these to function scope before the try block; keep only the
branch-local non-stream vars (finishReason/usage/toolCalls) where they
are. Same fix applied to handleMessages for startTime/messageId/reader/
bytesReceived/lastCcEvent/fullText, and declare the missing
finishReason/usage/toolCalls in the non-stream Anthropic branch (were
undefined, also a ReferenceError source).
fix: hoist TDZ-bound disconnect-handler vars + x-api-key fallback for Anthropic SDK
…ts, x-api-key auth, 429 zero-output, updated model list)
… non-stream)
CC upstream emits reasoning-delta for thinking; the Anthropic paths dropped it
(stream: empty break; non-stream: fell to default warn), so Claude Code never
saw thinking. Route it into standard Anthropic thinking content blocks:
- stream: content_block_start(type=thinking) -> thinking_delta -> signature_delta -> stop
- non-stream: accumulate reasoning-delta, emit {type:'thinking', thinking, signature}
- fake E-prefixed signature (base64, payload first byte 0x12) passes Claude Code's
shallow verification; request-side conversion still strips thinking so upstream
caching/billing are unaffected (verified: cache_read_input_tokens unchanged,
output_tokens are CC's real billing value including thinking)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )