Move src/ → apps/server/ and packages/web/ → apps/web/ to adopt standard monorepo conventions (apps/ for runnable apps, packages/ for reusable libraries). Update all config files, shared package imports, test fixtures, and documentation to reflect new paths. Key fixes: - Update workspace config to ["apps/*", "packages/*"] - Update tsconfig.json rootDir/include for apps/server/ - Add apps/web/** to vitest exclude list - Update drizzle.config.ts schema path - Fix ensure-schema.ts migration path detection (3 levels up in dev, 2 levels up in dist) - Fix tests/integration/cli-server.test.ts import paths - Update packages/shared imports to apps/server/ paths - Update all docs/ files with new paths
32 lines
996 B
TypeScript
32 lines
996 B
TypeScript
/**
|
|
* 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';
|