import type { Block, Message } from "@cubos/agent-sdk"; import { type ComponentType, type ReactNode } from "react"; /** * What draws one component, keyed by tag name — PascalCase, as the agent writes * it. * * Renderers only. What the *agent* is told about a component (its summary, the * prop schema, the example) lives in a component library the operator authors, * because those words go into the model's context verbatim and a browser must * not be the one writing them. Your app supplies the drawing half and the list * of library slugs it can draw; `useConversation` warns when the two disagree. * * Keep renderers here for components no enabled library offers any more — that * is what draws the components of older messages in the transcript. */ export type ComponentMap = Record>; export interface RenderBlocksOptions { components?: ComponentMap; /** Draws the prose between components. Without it the markdown is rendered as * plain text — correct, just not formatted; the SDK ships no markdown parser * and a chat app already has one. */ renderMarkdown?: (text: string) => ReactNode; /** * Wraps each rendered block, given the block it came from. * * The reason it takes the block and not just the node: laying blocks out * needs to know which are prose and which are components — two cards side by * side and the paragraph above them full width — and by the time a block is a * `ReactNode` that is gone. The SDK will not decide the layout (it renders no * DOM at all), so it hands back what the app needs to decide it. */ wrapBlock?: (node: ReactNode, block: Block) => ReactNode; } /** * The message split into nodes: prose through `renderMarkdown`, each component * block through the component registered under its tag. * * Null when the message carries no blocks — a user message, or an older server. * That distinction is real, so it is left to the caller rather than papered over * with `content`: a user's own text usually shouldn't go through a markdown * renderer at all. * * A tag with no component renders nothing. It means the set changed after the * message was written, and showing raw `` text would be worse than a * gap. */ export declare function renderBlocks(message: Message, options?: RenderBlocksOptions): ReactNode[] | null;