# All files / src/agent/providers/parsers index.ts

80% Statements 4/5
50% Branches 1/2
100% Functions 1/1
80% Lines 4/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32

    15x

    10x
    10x
    10x

     /**
     * Stream Parser Registry
     *
     * Factory function to get the appropriate stream parser for a provider.
     */

    import type { StreamParser } from '../stream-types.js';
    import { ClaudeStreamParser } from './claude.js';
    import { GenericStreamParser } from './generic.js';

    /** Map of provider names to parser constructors */
    const parserRegistry: Record<string, new () => StreamParser> = {
      claude: ClaudeStreamParser,
    };

    /**
     * Get a stream parser for the given provider.
     * Returns a provider-specific parser if available, otherwise the generic fallback.
     */
    export function getStreamParser(providerName: string): StreamParser {
      const ParserClass = parserRegistry[providerName];
      Eif (ParserClass) {
        return new ParserClass();
      }
      return new GenericStreamParser();
    }

    // Re-export types and parsers for direct access
    export type { StreamParser, StreamEvent } from '../stream-types.js';
    export { ClaudeStreamParser } from './claude.js';
    export { GenericStreamParser } from './generic.js';