import * as react_jsx_runtime from 'react/jsx-runtime'; import React from 'react'; import { ClassValue } from 'clsx'; /** * Table column definition */ interface TableColumn { key: string; label: string; type?: string; } /** * Table UI component for displaying tabular data */ interface TableComponent { type: 'table'; title?: string; columns: TableColumn[]; rows: Record[]; sortable?: boolean; paginated?: boolean; } /** * Chart dataset definition */ interface ChartDataset { label: string; data: number[]; color?: string; } /** * Chart UI component for data visualization */ interface ChartComponent { type: 'chart'; chart_type: 'bar' | 'line' | 'pie' | 'doughnut' | 'area'; title?: string; labels: string[]; datasets: ChartDataset[]; show_legend?: boolean; show_grid?: boolean; } /** * Card action button */ interface CardAction { label: string; action: string; variant?: 'primary' | 'secondary' | 'danger'; } /** * Card UI component for displaying content blocks */ interface CardComponent { type: 'card'; title: string; subtitle?: string; content?: string; image_url?: string; actions?: CardAction[]; variant?: 'default' | 'outlined' | 'elevated'; } /** * Discriminated union of all UI components */ type UIComponent = TableComponent | ChartComponent | CardComponent; /** * Type guard for TableComponent */ declare function isTableComponent(component: UIComponent): component is TableComponent; /** * Type guard for ChartComponent */ declare function isChartComponent(component: UIComponent): component is ChartComponent; /** * Type guard for CardComponent */ declare function isCardComponent(component: UIComponent): component is CardComponent; /** * Full response format (non-streaming) */ interface GenUIResponse { text: string; components: UIComponent[]; } /** * Events emitted during streaming */ type GenUIEvent = { type: 'text_delta'; value: string; } | { type: 'component'; payload: UIComponent; } | { type: 'done'; }; /** * Create a text delta event */ declare function textDelta(value: string): GenUIEvent; /** * Create a component event */ declare function componentEvent(payload: UIComponent): GenUIEvent; /** * Create a done event */ declare function doneEvent(): GenUIEvent; /** * Stream input types */ type StreamInput = EventSource | ReadableStream | Response; /** * Normalize any stream input to a GenUIEvent async iterator */ declare function normalizeStream(input: StreamInput): AsyncGenerator; /** * Convert a static response to GenUIEvents */ declare function normalizeResponse(response: GenUIResponse): Generator; interface GodComponentProps { /** Static response (non-streaming) */ response?: GenUIResponse; /** Streaming input (EventSource, ReadableStream, or Response) */ stream?: StreamInput; /** Callback when an action is triggered */ onAction?: (action: string) => void; /** Callback when streaming completes */ onComplete?: () => void; /** Callback on error */ onError?: (error: Error) => void; /** Custom class name */ className?: string; /** Gap between nodes */ gap?: 'sm' | 'md' | 'lg'; } /** * GodComponent - The main entry point for rendering Gen-UI responses * * Accepts either a static `response` or a `stream` (EventSource/ReadableStream) * and progressively renders text and UI components. */ declare function GodComponent({ response, stream, onAction, onComplete, onError, className, gap, }: GodComponentProps): react_jsx_runtime.JSX.Element | null; /** * Render node types for the render tree */ type RenderNode = { kind: 'text'; content: string; } | { kind: 'component'; component: UIComponent; }; /** * State for the GenUI reducer */ interface GenUIState { nodes: RenderNode[]; isStreaming: boolean; error: Error | null; } /** * Initial state */ declare const initialState: GenUIState; /** * Action types for the reducer */ type GenUIAction = { type: 'START_STREAMING'; } | { type: 'EVENT'; event: GenUIEvent; } | { type: 'STOP_STREAMING'; } | { type: 'SET_ERROR'; error: Error; } | { type: 'RESET'; }; /** * Reducer for building the render tree from events * * Rules: * - Text deltas append to the last text node (or create new one) * - Components are added as new nodes * - Order is strictly preserved */ declare function genUIReducer(state: GenUIState, action: GenUIAction): GenUIState; interface UseGenUIOptions { /** Static response (non-streaming) */ response?: GenUIResponse; /** Streaming input (EventSource, ReadableStream, or Response) */ stream?: StreamInput; /** Callback when streaming completes */ onComplete?: () => void; /** Callback on error */ onError?: (error: Error) => void; } interface UseGenUIResult { /** Current state */ state: GenUIState; /** Reset the state */ reset: () => void; /** Manually dispatch an event */ dispatch: (action: GenUIAction) => void; } /** * Hook to manage GenUI streaming state */ declare function useGenUI(options: UseGenUIOptions): UseGenUIResult; interface TextBlockProps { content: string; className?: string; } /** * Render text content with proper formatting * - Preserves whitespace and line breaks * - Uses semantic typography */ declare function TextBlock({ content, className }: TextBlockProps): react_jsx_runtime.JSX.Element | null; interface ComponentRendererProps { component: UIComponent; onAction?: (action: string) => void; className?: string; } /** * Render a UI component based on its type * Dispatches to the correct renderer from the registry */ declare function ComponentRenderer$1({ component, onAction, className }: ComponentRendererProps): react_jsx_runtime.JSX.Element; interface TableRendererProps { component: TableComponent; className?: string; } /** * Render a table component using ShadCN-style table */ declare function TableRenderer({ component, className }: TableRendererProps): react_jsx_runtime.JSX.Element; interface ChartRendererProps { component: ChartComponent; className?: string; } /** * Render a chart component using Tremor */ declare function ChartRenderer({ component, className }: ChartRendererProps): react_jsx_runtime.JSX.Element; interface CardRendererProps { component: CardComponent; onAction?: (action: string) => void; className?: string; } /** * Render a card component using ShadCN-style card */ declare function CardRenderer({ component, onAction, className }: CardRendererProps): react_jsx_runtime.JSX.Element; /** * Component renderer function signature */ type ComponentRenderer = React.FC<{ component: T; onAction?: (action: string) => void; className?: string; }>; /** * Register a component renderer */ declare function registerComponent(type: T['type'], renderer: ComponentRenderer): void; /** * Get a component renderer by type */ declare function getRenderer(type: string): ComponentRenderer | undefined; /** * Check if a renderer exists for a type */ declare function hasRenderer(type: string): boolean; /** * Get all registered types */ declare function getRegisteredTypes(): string[]; /** * Merge Tailwind classes with clsx */ declare function cn(...inputs: ClassValue[]): string; export { type CardAction, type CardComponent, CardRenderer, type ChartComponent, type ChartDataset, ChartRenderer, ComponentRenderer$1 as ComponentRenderer, type ComponentRenderer as ComponentRendererType, type GenUIAction, type GenUIEvent, type GenUIResponse, type GenUIState, GodComponent, type RenderNode, type StreamInput, type TableColumn, type TableComponent, TableRenderer, TextBlock, type UIComponent, cn, componentEvent, GodComponent as default, doneEvent, genUIReducer, getRegisteredTypes, getRenderer, hasRenderer, initialState, isCardComponent, isChartComponent, isTableComponent, normalizeResponse, normalizeStream, registerComponent, textDelta, useGenUI };