/**
 * 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];
  if (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';
