Commit Graph

4 Commits

  • fix: add Claude→Claude passthrough to prevent SSE event fragmentation
    When from==to (Claude→Claude scenario), directly forward SSE stream
    line-by-line without invoking TranslateStream. This preserves the
    multi-line SSE event structure (event:/data:/blank) and prevents
    JSON parsing errors caused by event fragmentation.
    
    Resolves: JSON parsing error when using Claude Code streaming responses
    
    fix: correct SSE event formatting in Handler layer
    
    Remove duplicate newline additions (\n\n) that were breaking SSE event format.
    The Executor layer already provides properly formatted SSE chunks with correct
    line endings, so the Handler should forward them as-is without modification.
    
    Changes:
    - Remove redundant \n\n addition after each chunk
    - Add len(chunk) > 0 check before writing
    - Format error messages as proper SSE events (event: error\ndata: {...}\n\n)
    - Add chunkIdx counter for future debugging needs
    
    This fixes JSON parsing errors caused by malformed SSE event streams.
    
    fix: update comments for clarity in SSE event forwarding
  • refactor(config): migrate to SDKConfig and streamline proxy handling
    - Replaced `config.Config` with `config.SDKConfig` across components for simpler configuration management.
    - Updated proxy setup functions and handlers to align with `SDKConfig` improvements.
    - Reorganized handler imports to match new SDK structure.