- Reorganized directory structure: pkg/ -> packages/, app/ -> apps/ - Added @hanzo/ai package with Vercel AI SDK patterns - Implemented AgentKit concepts (agents, networks, state, routers) - Added MCP (Model Context Protocol) integration - Integrated telemetry with Hanzo Cloud observability - Fixed all failing tests across all packages - Updated Makefile with comprehensive commands for development and release - Added support for Gemini, Codex, and Grok CLI tools - Fixed import paths and build configuration for new structure
25 lines
569 B
TypeScript
25 lines
569 B
TypeScript
import { createParser, ParsedEvent } from 'eventsource-parser';
|
|
|
|
export interface StreamPart {
|
|
type: 'text' | 'function_call' | 'tool_calls' | 'data' | 'error' | 'done';
|
|
value: any;
|
|
}
|
|
|
|
/**
|
|
* Parses a stream part from a server-sent event
|
|
*/
|
|
export function parseStreamPart(data: string): StreamPart | null {
|
|
try {
|
|
const parsed = JSON.parse(data);
|
|
return parsed;
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Creates an event source parser
|
|
*/
|
|
export function createEventSourceParser(onParse: (event: ParsedEvent) => void) {
|
|
return createParser(onParse);
|
|
} |