import { type ComponentType, type ReactNode } from 'react'; import type { AIUIHost } from '../GenerativeUI/AIUIHost'; import type { AIMessageAttachmentData } from '../Message/AIMessageAttachment'; import { type AIReplyActionsProps } from '../Message/AIReplyActions'; import type { AIMessagePartData } from '../MessageParts/types'; import { type AIToolApprover } from '../ToolCalls/AIToolApprover'; import type { AIMessage, AIPendingMessage } from './types'; import type { AIConversationController } from './controller/AIConversationController'; export type AIConversationUserMessageProps = { /** What the person sent with it, such as images and files. */ attachments: AIMessageAttachmentData[]; /** What the person wrote. */ text: string; /** The message, or `undefined` for one on its way. */ message?: AIMessage; /** Edits the message: a `conversation` offers it on the person's latest message. */ onEdit?: () => void; }; export type AIConversationAssistantMessageProps = { attachments: AIMessageAttachmentData[]; isGenerating: boolean; message: AIMessage; parts: AIMessagePartData[]; /** * Whether the UI the agent wrote for the reply shows, in place of its words, which `text` then * leaves out. `false` for a reply with no UI, one the conversation's `ui` host has no renderer * for, one whose renderer shows nothing of it, and one whose UI failed (`uiFailed`). A reply * that is neither generating nor showing UI, with no `text`, finished without a text reply, * for which a message can show a status of its own. */ showsUI: boolean; /** What the reply says, or `''` while its UI shows in place of its words (`showsUI`). */ text: string; /** * Whether the reply has UI that failed to show (`AIUIHost.fail`), so its words, if any, show * instead. The message renders again when it fails, whether or not it is memoised. */ uiFailed: boolean; approver?: AIToolApprover; reasoningText?: (stepId: string) => string | undefined; }; export type AIConversationReplyActionsProps = { /** Whether it is the reply that ends the conversation, which can be asked for again. */ isLatestReply: boolean; message: AIMessage; text: string; }; export type AIConversationProps = { /** * The conversation's state and what the person does in it, such as an * `AIConversationController`. The conversation shows its messages, the message on its way and * whether the agent thinks, loads its older messages, and offers rating and regenerating * replies and editing the person's latest message. It takes the place of `messages`, * `pendingMessage`, `isThinking` and `loadOlderMessages`, its reply actions are used unless * `replyActions` is passed, and its `approver` unless one is passed. */ conversation?: AIConversationController; /** The conversation, oldest message first. Required without `conversation`. */ messages?: AIMessage[]; /** Who answers tool calls' questions and sign-ins on this device, to ask them. */ approver?: AIToolApprover; /** The view of the agent's replies. Defaults to `AIAssistantMessage`. */ AssistantMessage?: ComponentType; /** * Room left under the latest turn, in pixels, for a composer floating over the bottom of the * conversation. The question of a new turn pins to the top of what is visible above it. */ bottomInset?: number; className?: string; /** What the conversation shows while there are no messages, centered in it. */ emptyContent?: ReactNode; /** A view under the latest turn's messages, such as what the agent is doing, or an error with a way to retry. */ footer?: ReactNode; /** * Whether the agent is answering the latest message and its reply shows nothing yet. * Meanwhile the latest turn ends with `AIThinking`, and the reply's first reasoning step takes * over its seconds. The conversation also knows it is while `pendingMessage` waits, and while * the latest reply is being written but shows nothing. */ isThinking?: boolean; /** * Loads the messages before the first one, which the conversation asks for as the person * scrolls to its start. It shows a spinner meanwhile, and what is on screen stays in place as * they arrive. Pass `undefined` once there are none left. */ loadOlderMessages?: () => Promise | void; /** * A message the person sent that is not in `messages` yet. Keep passing it until its reply * starts: the conversation stops showing it once its copy arrives. */ pendingMessage?: AIPendingMessage | null; /** The actions under each finished reply. Defaults to `AIReplyActions`; `null` shows none. */ ReplyActions?: ComponentType | null; /** * What the default `AIReplyActions` offers for a reply besides copy and share, such as its * rating and how to rate or regenerate it. */ replyActions?: (message: AIMessage, context: { isLatestReply: boolean; }) => Omit | undefined; /** * Shows the UI the agent writes for its replies (`AIMessage.uiDocument`) in place of their * text, with the renderers of the formats it writes, such as A2UI. A reply whose UI none of * them shows shows its text. Keep one host per conversation, for as long as it shows. */ ui?: AIUIHost; /** The view of the person's messages. Defaults to `AIUserMessage`. */ UserMessage?: ComponentType; }; /** * The conversation with an AI agent, laid out by turn: each of the person's questions starts * a turn, with the agent's reply under it. The counterpart of `AIConversationView`. * * - A new question pins to the top of what is visible, and the reply writes out below it, * without moving what is on screen. The latest turn is at least as tall as the conversation. * - It opens at the end; older messages load as the person scrolls to the start, and what is * on screen stays in place as they arrive. * - A button scrolls back to the latest message when the end is out of view. * - A message the person sent shows at once (`pendingMessage`) and the agent thinks under it * (`AIThinking`) until its reply shows something. * * With a `conversation`, such as an `AIConversationController`, it shows the conversation's * state and offers what the person can do in it. Without one, pass its `messages` and the rest. */ export declare const AIConversation: (props: AIConversationProps) => import("react/jsx-runtime").JSX.Element; //# sourceMappingURL=AIConversation.d.ts.map