veryfront/chat

Import

TypeScript
import { AgentCard, agentsToPickerOptions, Chat, Message, useAgent, useChat } from "veryfront/chat";

Examples

Basic chat (preset)

TSX
import { Chat, useChat } from "veryfront/chat"; export default function Page() {  const chat = useChat();  return <Chat chat={chat} />;}

Custom layout (composition)

TSX
import { Chat, useChat } from "veryfront/chat"; export default function Page() {  const chat = useChat();  return (    <Chat.Root messages={chat.messages} input={chat.input}>      <Chat.If condition={(ctx) => ctx.isEmpty}>        <Chat.Empty title="Ask me anything" />      </Chat.If>      <Chat.MessageList messages={chat.messages} />      <Chat.Input        input={chat.input}        onChange={chat.handleInputChange}        onSubmit={chat.handleSubmit}      />    </Chat.Root>  );}

Per-message control (compound)

TSX
import { Message } from "veryfront/chat"; <Message.Root message={msg}>  <Message.Avatar />  <Message.Content />  <Message.Actions /></Message.Root>;

Type Reference

UseChatOptions

Options accepted by use chat.

PropertyTypeDescriptionSource
api?stringAG-UI endpoint. Defaults to "/api/ag-ui".source
transport?"ag-ui"Streaming response protocol used by the endpoint. AG-UI is the default.source
initialMessages?ChatMessage[]Pre-populated messagessource
body?<code>Record<string, unknown></code>Extra body fields sent with each requestsource
headers?<code>Record<string, string></code>Custom request headerssource
credentials?RequestCredentialsFetch credentials modesource
model?stringOverride model at runtime (e.g. "openai/gpt-4o", "Anthropic/claude-sonnet-4-5-20250929")source
onResponse?<code>(response: Response) => void</code>Raw response callbacksource
onFinish?<code>(message: ChatMessage) => void</code>Completion callbacksource
onError?<code>(error: UseChatError) => void</code>Error callbacksource
onToolCall?<code>(arg: OnToolCallArg) => void | Promise<void></code>Tool call handler for client-side executionsource

UseChatResult

useChat result

PropertyTypeDescriptionSource
messagesChatMessage[]All messages in the conversationsource
inputstringCurrent input valuesource
isLoadingbooleanWhether a request is in flightsource
statusChatStatusStreaming lifecycle of the current turn (AI-SDK parity).source
streamingMessageIdstring | nullId of the assistant message currently streaming, or null when idle.source
errorUseChatError | nullLast error (if any)source
modelstring | undefinedCurrent model override (undefined = use agent default)source
activeModelstring | undefinedThe actual model being used after auto-upgrade (e.g. "Anthropic/claude-sonnet-4-20250514")source
inferenceModeInferenceModeWhere inference is currently happeningsource
setInput<code>(input: string) => void</code>Set input valuesource
setModel<code>(model: string | undefined) => void</code>Change the model for subsequent requestssource
sendMessage<code>(message: { text: string; files?: ChatFilePart[]; model?: string }) => Promise<void></code>Send a message. A message model overrides the session model for this request only.source
editMessage<code>(messageId: string, newText: string) => Promise<void></code>Edit a user message and resubmit - truncates history to that pointsource
getBranches<code>(messageId: string) => BranchInfo</code>Get branch info for a message (returns { current, total }; total=1 if no branches)source
switchBranch<code>(messageId: string, branchIndex: number) => void</code>Switch to a different branch at a given messagesource
reload<code>() => Promise<void></code>Re-send last user messagesource
stop<code>() => void</code>Abort current requestsource
setMessages<code>(messages: ChatMessage[]) => void</code>Replace message historysource
addToolOutput<code>(output: ToolOutput) => void</code>Submit client-side tool resultsource
data?unknownExtra data from server responsesource
handleInputChange<code>(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void</code>Bind to input onChangesource
handleSubmit<code>(e?: React.FormEvent) => Promise<void></code>Submit current inputsource

UseAgentOptions

Options accepted by use agent.

PropertyTypeDescriptionSource
agentstringAgent ID or endpointsource
onToolCall?<code>(toolCall: ToolCall) => void</code>Callback when tool is calledsource
onToolResult?<code>(toolCall: ToolCall, result: unknown) => void</code>Callback when tool result receivedsource
onError?<code>(error: Error) => void</code>Callback when error occurssource

UseAgentResult

Result returned from use agent.

PropertyTypeDescriptionSource
messagesAgentMessage[]Message historysource
toolCallsToolCall[]Active tool callssource
statusAgentStatusAgent statussource
thinking?stringThinking/reasoning textsource
invoke<code>(input: string) => Promise<void></code>Invoke the agentsource
stop<code>() => void</code>Stop agent executionsource
isLoadingbooleanLoading statesource
errorError | nullError statesource

Exports

Components

NameDescriptionSource
AgentAvatarRender agent avatar, falling back to model identity when agent identity is absent.source
AgentCardAgentCard - render <AgentCard {...props} /> for the default card, or compose AgentCard.Header / Reasoning / Tools / Body for a custom layout. Mirrors the ToolCall compound: render it, or compose it.source
AgentPickerAgentPicker - render <AgentPicker agents={...} .../> for the default data-driven combobox, or compose AgentPicker.Trigger, Content, Search, List, Item, Create, and Manage for a custom menu.source
AppShellCompound AppShell. Compose:source
AttachmentPillAttachmentPill - render <AttachmentPill attachment={…} /> for the default chip, or compose AttachmentPill.Root + .Thumbnail / .Icon / .Label / .Retry / .Remove for a custom layout.source
AttachmentsPanelAttachmentsPanel - render <AttachmentsPanel uploads={…} /> for the default panel, or compose AttachmentsPanel.Root + List / Item / Empty / Action for a custom layout. Mirrors the ToolCall / Sources compounds: render it, or compose it.source
BranchPickerBranch picker with addressable previous, count, and next leaves.source
ChatRender chat components through the preset or its composable sub-parts.source
ChatActionsChatActions - render <ChatActions onAttachFiles={…} actions={…} /> for the default preset menu, or compose ChatActions.Trigger / Content / Item (each reads useChatActions()) for a custom menu. Mirrors the ToolCall compound: render it, or compose it.source
ChatAgentPickerRender the connected agent switcher, or nothing when there's nothing to switch.source
ChatContextProviderRender chat context provider.source
ChatEmptyRender the chat empty state. It renders whatever it is given and never hides itself: in a custom layout, gate it on the thread being empty with <Chat.If condition={(ctx) => ctx.isEmpty}>. The <Chat> preset does this for you.source
ChatEmptyStateCompound empty state. Use the namespaced parts to compose the view: Root, Avatar, Heading, Suggestions, Suggestion.source
ChatIfRender chat if.source
ChatInputChatInput - render <ChatInput … /> for the default composer, or compose ChatInput.Field + ChatInput.Send/Stop/Voice/Model/Attach/Export.source
ChatInputAttachAttachment + control. When attaching files is the only action, + opens the file dialog directly. When onSelectAttachment is also set it becomes a portalled + menu (Studio PromptForm's PlusMenu) with "Add photos & files" and "Select document".source
ChatInputContextProviderProvider for <ChatInput> context.source
ChatInputExportDownload the supplied conversation as Markdown.source
ChatInputFieldThe multiline text editor.source
ChatInputModelModel selector - shows when models are configured.source
ChatInputRootChatInput.Root - the provider shell for a fully custom composer. Supplies ChatInputContext from props and renders your children, so you arrange ChatInput.Field + the toolbar sub-parts yourself (like Message.Root). The default <ChatInput> is exactly this Root plus the standard body. Omitted props fall back to the surrounding ChatContext (<Chat.Root chat={…}>), so a propless Root wires itself to the shared session; explicit props win.source
ChatInputSendSend button, shown while the composer is idle.source
ChatInputStopStop button, shown while the composer is streaming.source
ChatInputSubmitSwitch between send and stop states with one control.source
ChatInputToolbarChatInput.Toolbar - a semantic layout slot for the composer's action row. Group/reorder the action sub-parts (ChatInput.Attach/.Model/.Export/ .Voice/.Send) inside it without re-implementing the composer. Pure layout: the children read their own ChatInputContext, so <ChatInput.Toolbar> just mirrors the default action-row wrapper classes.source
ChatInputVoiceVoice button, shown when the idle composer is empty.source
ChatMessageListRender the default message list or compose its centered Content column.source
ChatMessagesSkeletonRender the loading skeleton for a chat thread.source
ChatRootRender chat root.source
ChatSidebarRender a chat sidebar - usable as <ChatSidebar /> or <ChatSidebar.Root>….source
ChatThemeScopeWrap chat primitives in the [data-vf-ui] token scope so they're themed.source
CodeBlockRender escaped source or delegate to explicit syntax/diagram capabilities.source
CodeSurfaceRender through an explicit extension capability or escaped plain source.source
CONVERSATION_STORAGE_LIMITSExplicit resource limits applied on both the read and write paths.source
ConversationEmptyStateState for conversation empty.source
ConversationsContextProviderLow-level context provider (value supplied by the caller).source
ConversationScrollButtonRender conversation scroll button.source
ConversationsProviderConversationsProvider - calls useConversations once with your store / id / onSelect and shares it via ConversationsContext. Declare persistence + router wiring here, once, at the app layout; children read it with useConversationsContext.source
CopyButtonsource
DEFAULT_CHAT_STREAM_IDLE_TIMEOUT_MSDefault value for chat stream idle timeout ms.source
DEFAULT_CHAT_STREAM_TOOL_RUNNING_TIMEOUT_MSDefault value for chat stream tool running timeout ms.source
DropZoneOverlayDrag overlay shown over the composer while files are dragged onto it - the glyph-in-a-circle + "Drop files" from Studio's PromptForm. Rendered inside a relative card; fills it and blurs the content behind.source
ErrorBannerRender error banner. Mirrors Studio's inline chat retry banner: an amber warning alert with a leading triangle icon and a small filled "Try again" button (not a low-emphasis error pill).source
FadeInRender fade in.source
InferenceBadgeRender inference badge.source
InlineCitationRender the default citation or compose its Trigger and Card parts.source
LoaderRender loader.source
MarkdownPresent Markdown source using an injected rich renderer or the explicit dependency-free plain-source contract.source
MessageMessage - render <Message message={msg} /> for the default turn, or compose Message.Root + Message.Header/Content/Actions/… for a custom layout.source
MessageActionBarContext-free message actions with addressable Copy, Copied, Regenerate, and Edit icon leaves.source
MessageContextProviderRender message context provider.source
MessageEditFormRender message edit form.source
MessageFeedbackMessage feedback with addressable positive and negative action leaves.source
ModelAvatarRender model avatar.source
ModelSelectorModelSelector - render <ModelSelector models={...} .../> for the default data-driven combobox, or compose ModelSelector.Trigger, Content, Search, List, and Item for a custom menu.source
QuickActionsRender quick actions.source
ReasoningReasoning - render <Reasoning text={…} /> for the default disclosure, or compose Reasoning.Trigger + Reasoning.Content for a custom layout. Mirrors the Message / ToolCall compounds: render it, or compose it.source
ShimmerRender shimmer.source
SkillBadgeRender skill badge.source
SourcePillRender a single source pill with hover preview and score-color behaviour.source
SourcesSources - render <Sources sources={…} /> for the default row, or compose Sources.Root + Sources.List + Sources.Pill for a custom layout. Mirrors the ToolCall / Reasoning compounds: render it, or compose it.source
StepIndicatorStepIndicator - render <StepIndicator stepIndex={…} isComplete /> for the default divider, or compose StepIndicator.Root + .Rule / .Label for a custom layout. Mirrors the ToolCall / Sources compounds.source
SuggestionRender suggestion.source
SuggestionsRender suggestions.source
TabsTablist container - delegates selection to the adapter, owns the size + look.source
TabsItemIndividual tab - renders as a button, or an anchor when href is set. The adapter's tabs.Tab supplies the role="tab" / aria-selected / data-state mechanics and composes selection onto the caller's onClick (caller's runs first, then the tab activates); this skin renders the visual pill and forwards native props/ref.source
TabSwitcherRender tab switcher.source
ToolCallToolCall - render <ToolCall tool={part} /> for the default card. invoke_agent calls use a child-agent card by default. Pass children to replace the default, or compose ToolCall.Trigger / Body / Input / Output / Error for a custom layout. Mirrors the Message compound: render it, or compose it.source
ToolStatusBadgeRender tool status badge.source

Functions

NameDescriptionSource
agentsToPickerOptionsNarrow browser-safe agent metadata to the picker's row shape. AgentOption now shares AgentMetadata's avatarUrl field, so AgentMetadata[] is also accepted by <AgentPicker agents> directly - this helper just drops the fields the rows don't use.source
buildChatStreamChunkMessageMetadataBuilds chat stream chunk message metadata.source
createChatStreamWatchdogCreate chat stream watchdog backed by the lifecycle deadline primitive.source
createChatStreamWatchdogStateState for create chat stream watchdog.source
dedupeChatUiMessageChunksDedupe chat UI message chunks.source
downloadMarkdownDownload messages as a .md file.source
exportAsMarkdownConvert chat messages to a markdown string.source
extractChatMessageMetadataExtract chat message metadata.source
extractSourcesFromPartsExtract sources from native citations and tool result parts. Native source parts map directly, while tool outputs may expose a documents array.source
getAgentPromptSuggestionItemsNormalize an agent's prompt suggestions to { label, prompt }[], ready to render - the chip shows the short title while the click sends the full prompt. Saves consumers from flat-mapping agent.suggestions.suggestions and reconciling the title/prompt fields themselves.source
getAgentPromptSuggestionsReturn prompt text suggestions that the current Chat component can render.source
getNextChatStreamWatchdogStateState for get next chat stream watchdog.source
getTextContentGet text content from chat message partssource
groupPartsInOrderGroup consecutive parts for ordered rendering Returns an array of groups, each containing either consecutive text parts, a tool part, or a reasoning partsource
isHeartbeatOnlyMetadataChunkCheck whether a chunk only carries heartbeat metadata.source
isLongRunningToolRunningCompatibility helper. Under strict lifecycle deadlines long-running tool names no longer disable the absolute tool-running deadline; in legacy mode they still do. Also exported for callers that classify tool activity.source
isReasoningPartCheck if a part is a reasoning partsource
isSkillToolPartCheck if a tool part is a skill-related tool.source
isToolPartCheck if a part is a tool partsource
localConversationStorelocalStorage-backed conversation persistence. Pass a storage to back it with another Web-Storage-like implementation. Every operation requires the Web Locks API so concurrent browser contexts cannot lose index updates.source
mapHostedStreamPartToChatUiChunksMap hosted stream part to chat UI chunks.source
memoryConversationStoreIn-memory conversation persistence. Optionally seed with initial conversations.source
mergePropsMerge one override object onto base props: on* handlers compose (override first, internal skipped if defaultPrevented), className concatenates via cx (consumer appended last), everything else is override-wins. Exported for composing several getters onto one element.source
normalizeAgentMetadataNormalize a single browser-safe agent record (the agent object inside the /api/agents/:id response, or one entry of the /api/agents list).source
normalizeAgentMetadataResponseNormalize the wire response from /api/agents/:id.source
normalizeAgentsListResponseNormalize the wire response from GET /api/agents.source
normalizeChatMessageMetadataNormalizes chat message metadata.source
normalizeChatUiMessageChunkNormalizes chat UI message chunk.source
normalizeChatUiMessageStreamNormalizes chat UI message stream.source
useAgentReact hook for agent.source
useAgentMetadataReact hook for browser-safe source-defined agent metadata.source
useAgentsReact hook that lists the browser-safe agents a project exposes, via GET /api/agents. Companion to useAgentMetadata (single agent) - use it to drive an agent switcher, e.g. only rendering a picker when agents.length > 1.source
useAttachmentsuseAttachments - the headless state hook for chat attachments: a persistent, cross-conversation registry of uploaded files with the upload / remove / list actions. This is the domain primitive; render any UI on top of it (the AttachmentsPanel / AttachmentPill components are one skin - bring your own).source
useChatThe core chat session hook: manages messages, streaming status, input, submit, regenerate, and branch navigation for a conversation. Powers <Chat> (L1) and is the L3 headless entry point for building a fully custom chat UI.source
useChatContextOptionalReact hook for chat context optional.source
useChatErrorHandlerHandler for use chat error.source
useChatInputL3 headless composer hook. Must be used within a <ChatInput> / <Chat>.source
useChatInputContextOptionalRead the enclosing <ChatInput> context, or null outside one.source
useChatScrollTrack and maintain bottom-pinned scroll behavior for a chat viewport.source
useClipboardCopy text and expose transient success or failure feedback.source
useCompletionuseCompletion hook for single text generationsource
useConversationLoad one full conversation by id, over a swappable async store.source
useConversationChatBind the active conversation to an isolated chat session and persistence sink.source
useConversationsList + active + persistence for conversations, over a swappable async store.source
useConversationsContextOptionalRead the shared conversations state, or null when there is no provider.source
useMessageBranchesuseMessageBranches is a thin hook over the message context's branch state (getBranches / switchBranch on useChat, surfaced as branch + onBranchPrev/Next). Powers Message.BranchPicker; RFC 2980. Must be used within a <Message>.source
useMessageContextOptionalReact hook for message context optional.source
useMessagePartsuseMessageParts - read the current message's parts as data, so a consumer can render them however they like (the headless access point to parts; Message.Part is the leaf and Message.Content provides the default rendering). Throws outside a Message.source
useStreamingReact hook for streaming.source
useUploadDrive file uploads and expose the resulting attachment lifecycle.source
useVoiceInputInput payload for use voice.source

Classes

NameDescriptionSource
ChatErrorBoundaryImplement chat error boundary.source
ChatStreamIdleTimeoutErrorError shape for chat stream idle timeout.source
ConversationStoreErrorNormalized persistence failure. Store implementations should reject rather than resolve when an operation did not complete; the React hooks wrap custom adapter rejections in this error so consumers can branch on operation without parsing an error message.source

Types

NameDescriptionSource
ActiveConversationLoadFailureA failed provider-owned active-record load, attributed to its exact id.source
AgentAvatarPropsProps accepted by agent avatar.source
AgentCardContextValuePer-card state shared with AgentCard.* sub-parts.source
AgentCardPropsProps accepted by agent card.source
AgentMetadataBrowser-safe source-defined agent metadata.source
AgentMetadataPromptSuggestionSource-defined prompt suggestion shown by chat surfaces.source
AgentMetadataSuggestionSource-defined agent suggestion.source
AgentMetadataSuggestionsSource-defined suggestion group for an agent.source
AgentMetadataTaskSuggestionSource-defined task suggestion shown by chat surfaces.source
AgentOptionA selectable agent entry.source
AgentPickerActionPropsProps shared by AgentPicker.Create and AgentPicker.Manage.source
AgentPickerContentPropsProps for AgentPicker.Content, the popover surface and Command shell.source
AgentPickerContextValueShared selection and open state exposed to AgentPicker.* sub-parts.source
AgentPickerItemPropsProps for AgentPicker.Item, a single selectable agent row.source
AgentPickerPropsProps accepted by <AgentPicker>.source
AgentPickerSearchPropsProps for AgentPicker.Search, the addressable search input leaf.source
AgentPickerSectionA labelled group of agents (e.g. "Connected Agents").source
AgentPickerTriggerPropsProps for AgentPicker.Trigger, the pill/input combobox button.source
AgentThemePublic API contract for agent theme.source
AppShellHeaderPropsProps accepted by AppShellHeader.source
AppShellOpenStatePer-side visibility map.source
AppShellPropsProps accepted by AppShell.source
AppShellSideWhich edge a sidebar docks to.source
AppShellSidebarPropsProps accepted by AppShellSidebar.source
AppShellTriggerPropsProps accepted by AppShellTrigger.source
AttachmentInfoPublic API contract for attachment info.source
AttachmentPillContextValueDerived per-pill view state shared with AttachmentPill.* sub-parts.source
AttachmentPillPropsProps accepted by attachment pill.source
AttachmentsPanelActionPropsProps for AttachmentsPanel.Action - the upload/attach button.source
AttachmentsPanelContextValuePer-panel state shared with AttachmentsPanel.* sub-parts.source
AttachmentsPanelEmptyPropsProps for AttachmentsPanel.Empty - the no-files state.source
AttachmentsPanelHeaderPropsProps for AttachmentsPanel.Header - the title row + close button.source
AttachmentsPanelItemPropsProps accepted by an individual AttachmentsPanel.Item (attachment card).source
AttachmentsPanelListPropsProps for AttachmentsPanel.List - the scrollable list of file rows.source
AttachmentsPanelLoadingPropsProps for AttachmentsPanel.Loading - the initial-fetch placeholder.source
AttachmentsPanelPropsProps accepted by AttachmentsPanel / AttachmentsPanel.Root.source
BranchInfoPublic API contract for branch info.source
BranchPickerActionPropsProps shared by BranchPicker.Previous and BranchPicker.Next.source
BranchPickerCountPropsProps accepted by BranchPicker.Count.source
BranchPickerPropsProps accepted by branch picker.source
BuildChatStreamChunkMessageMetadataInputInput payload for build chat stream chunk message metadata.source
ChatActionItemA single data-driven action row in the <ChatActions> menu.source
ChatActionsContentPropsProps for ChatActions.Content, the dropdown surface.source
ChatActionsContextValueShared state exposed to ChatActions.* sub-parts via useChatActions().source
ChatActionsItemPropsProps for ChatActions.Item, a single selectable menu row.source
ChatActionsPropsProps accepted by <ChatActions> / <ChatActions.Root>.source
ChatActionsSettingsThe two toggle settings surfaced in the Settings submenu.source
ChatActionsSlottedTriggerPropsLiteral slotted-element props for ChatActions.Trigger.source
ChatActionsTriggerPropsBackward-compatible props for ChatActions.Trigger.source
ChatAgentInfoAgent identity + agent-driven content for <Chat>. Collapses the old agent / models / suggestion props into one object. In app mode (agentId) this is derived from agent metadata automatically; pass it yourself to drive a controlled chat.source
ChatAgentPickerPropsProps accepted by <ChatAgentPicker>.source
ChatContextValuePublic API contract for chat context value.source
ChatDynamicToolPartPublic API contract for chat dynamic tool part.source
ChatEmptyPropsProps accepted by chat empty.source
ChatEmptyStateAvatarPropsProps accepted by <ChatEmptyState.Avatar>.source
ChatEmptyStateHeadingPropsProps accepted by <ChatEmptyState.Heading>.source
ChatEmptyStateRootPropsProps accepted by <ChatEmptyState.Root>.source
ChatEmptyStateSuggestionPropsProps accepted by <ChatEmptyState.Suggestion>.source
ChatEmptyStateSuggestionsPropsProps accepted by <ChatEmptyState.Suggestions>.source
ChatErrorBoundaryPropsProps accepted by chat error boundary.source
ChatFinishReasonPublic API contract for chat finish reason.source
ChatIfPropsProps accepted by chat if.source
ChatInputActionPropsBackward-compatible props shared by every ChatInput action leaf.source
ChatInputAttachPropsProps accepted by <ChatInput.Attach>.source
ChatInputContextValuePublic API contract for the chat input context value.source
ChatInputExportPropsProps accepted by <ChatInput.Export>.source
ChatInputFieldPropsProps accepted by <ChatInput.Field>.source
ChatInputModelPropsProps accepted by <ChatInput.Model>.source
ChatInputPropsProps accepted by ChatInput.source
ChatInputRootPropsProps accepted by <ChatInput.Root>.source
ChatInputSendPropsProps accepted by <ChatInput.Send>.source
ChatInputSlottedActionPropsLiteral slotted action contract with an element-specific ref and event.source
ChatInputSlottedSubmitPropsLiteral slotted props for the unified ChatInputSubmit control.source
ChatInputStopPropsProps accepted by <ChatInput.Stop>.source
ChatInputSubmitPropsProps for the unified ChatInputSubmit control.source
ChatInputToolbarPropsProps accepted by <ChatInput.Toolbar>.source
ChatInputVoicePropsProps accepted by <ChatInput.Voice>.source
ChatMessageMessage shape for chat.source
ChatMessageListContentPropsProps accepted by the centered transcript column.source
ChatMessageListPropsProps accepted by chat message list.source
ChatMessageMetadataPublic API contract for chat message metadata.source
ChatMessageMetadataUsagePublic API contract for chat message metadata usage.source
ChatMessagePartPublic API contract for chat message part.source
ChatMessagesSkeletonPropsProps accepted by <ChatMessagesSkeleton>.source
ChatPropsProps accepted by chat.source
ChatReasoningPartChat message part that carries reasoning text.source
ChatRootPropsProps accepted by chat root.source
ChatSidebarComponentCompound type - the preset plus its namespaced sub-components.source
ChatSidebarEmptyPropsProps accepted by ChatSidebarEmpty.source
ChatSidebarGroupPropsProps accepted by ChatSidebarGroup.source
ChatSidebarItemPropssource
ChatSidebarItemTitlePropsProps for ChatSidebarItemTitle.source
ChatSidebarListPropsProps accepted by ChatSidebarList.source
ChatSidebarNewButtonPropsProps accepted by ChatSidebarNewButton.source
ChatSidebarPropsProps accepted by the ChatSidebar preset.source
ChatSidebarRootPropsProps accepted by ChatSidebarRoot.source
ChatStepPartPublic API contract for chat step part.source
ChatStreamEventEvent emitted for chat stream.source
ChatStreamWatchdogOptionsOptions accepted by chat stream watchdog.source
ChatStreamWatchdogPhasePublic API contract for chat stream watchdog phase.source
ChatStreamWatchdogStateState for chat stream watchdog.source
ChatTabPublic API contract for chat tab.source
ChatTextPartChat message part that carries text.source
ChatThemePublic API contract for chat theme.source
ChatThemeScopePropsProps accepted by ChatThemeScope.source
ChatToolPartPublic API contract for chat tool part.source
ChatToolResultPartChat message part that carries a tool result.source
ChatToolStateState for chat tool.source
ChatUiMessageChunkPublic API contract for chat UI message chunk.source
ChildRunAuditPublic API contract for child run audit.source
ChildRunAuditToolCallPublic API contract for child run audit tool call.source
ChildRunAuditToolResultResult returned from child run audit tool.source
CodeSurfacePropsProps accepted by CodeSurface.source
ConversationA full conversation - metadata + its messages. Fetched via ConversationStore.load.source
ConversationEmptyStatePropsProps accepted by conversation empty state.source
ConversationPatchFields a conversation can be patched with.source
ConversationsContextValueValue accepted by the low-level context provider. Persistence state and activeReady are optional here so existing caller-supplied structural fixtures remain compatible; ConversationsProvider always supplies them.source
ConversationScrollButtonPropsProps accepted by conversation scroll button.source
ConversationsProviderPropsProps accepted by ConversationsProvider.source
ConversationStorageLimitsNamed shape of the local conversation codec's public resource limits.source
ConversationStoreAsync persistence contract for conversations. Implement all four methods; subscribe/dispose are optional capabilities (feature-detect them).source
ConversationStoreOperationPersistence operation associated with a ConversationStoreError.source
ConversationSummaryLightweight conversation metadata - what a list / sidebar needs (no messages).source
CopyButtonPropsProps accepted by CopyButton.source
DropZoneOverlayPropsProps accepted by drop zone overlay.source
ErrorBannerPropsProps accepted by error banner.source
FeedbackValuePublic API contract for feedback value.source
HostedStreamPartForUiChunkMappingPublic API contract for hosted stream part for UI chunk mapping.source
HostedUiChunkMappingOptionsOptions accepted by hosted UI chunk mapping.source
InferenceBadgePropsProps accepted by inference badge.source
InferenceModeWhere inference is happening.source
InlineCitationCardPropsProps accepted by InlineCitation.Card.source
InlineCitationPropsProps accepted by inline citation.source
InlineCitationTriggerPropsProps accepted by InlineCitation.Trigger.source
MarkdownPropsProps accepted by Markdown.source
MessageActionBarActionPropsProps shared by the MessageActionBar.* action leaves.source
MessageActionBarPropsProps accepted by the context-free message action bar.source
MessageContextValuePublic API contract for message context value.source
MessageEditFormPropsProps accepted by message edit form.source
MessageFeedbackActionPropsProps shared by MessageFeedback.Positive and MessageFeedback.Negative.source
MessageFeedbackPropsProps accepted by message feedback.source
MessagePartsDataThe message's grouped parts exposed as headless data.source
MessagePropsProps accepted by <Message />.source
MessageRootPropsProps accepted by message root.source
MessageTokensPropsProps accepted by Message.Tokens.source
ModelAvatarPropsProps accepted by model avatar.source
ModelOptionA "provider/model" value and its display label.source
ModelSelectorContentPropsProps for ModelSelector.Content - the popover surface + Command shell.source
ModelSelectorContextValueShared selection + open state exposed to ModelSelector.* sub-parts.source
ModelSelectorItemPropsProps for ModelSelector.Item - a single selectable model row.source
ModelSelectorPropsProps accepted by <ModelSelector>.source
ModelSelectorSearchPropsProps for ModelSelector.Search, the addressable search input leaf.source
ModelSelectorTriggerPropsProps for ModelSelector.Trigger - the pill/icon combobox button.source
OnToolCallArgPublic API contract for on tool call arg.source
PartGroupPart group types for ordered renderingsource
PromptSuggestionA prompt suggestion normalized for rendering: the short label shown on the chip and the full prompt sent when it is clicked.source
QuickActionPublic API contract for quick action.source
QuickActionsPropsProps accepted by quick actions.source
ReasoningContextValuePer-card state shared with Reasoning.* sub-parts.source
ReasoningPropsProps accepted by Reasoning / Reasoning.Root.source
ReasoningTriggerPropsProps for Reasoning.Trigger - the disclosure button.source
SkillBadgePropsProps accepted by skill badge.source
SourcePublic API contract for source.source
SourcePillPropsProps accepted by an individual source pill.source
SourcesContextValuePer-list state shared with Sources.* sub-parts.source
SourcesListPropsProps for Sources.List - the flex-wrap row of pills.source
SourcesPropsProps accepted by Sources / Sources.Root.source
StepIndicatorContextValuePer-indicator state shared with StepIndicator.* sub-parts.source
StepIndicatorPropsProps accepted by step indicator.source
StorageLikeThe slice of the Web Storage API this adapter needs.source
SuggestionPropsProps accepted by suggestion.source
SuggestionsPropsProps accepted by suggestions.source
TabsItemPropsProps accepted by <TabsItem>.source
TabsPropsProps accepted by <Tabs> (the tablist container).source
TabSwitcherPropsProps accepted by tab switcher.source
TokenRowPropsOne row in the token usage breakdown.source
ToolCallContextValuePer-tool state shared with ToolCall.* sub-parts.source
ToolCallPropsProps accepted by ToolCall / ToolCall.Root.source
ToolCallTriggerPropsProps for ToolCall.Trigger - the header button.source
ToolOutputOutput from tool.source
UploadedFilePublic API contract for uploaded file.source
UseAgentMetadataResultResult returned from useAgentMetadata.source
UseAgentOptionsOptions accepted by use agent.source
UseAgentResultResult returned from use agent.source
UseAgentsOptionsOptions accepted by useAgents.source
UseAgentsResultResult returned from useAgents.source
UseAttachmentsOptionsOptions for useAttachments.source
UseAttachmentsRequestStateAdditive remote-request status returned by useAttachments.source
UseAttachmentsResultResult of useAttachments.source
UseAttachmentsStorageStateAdditive cache-status contract returned by useAttachments.source
UseChatErrorError exposed by useChat state and callbacks.source
UseChatInputResultResult of useChatInput.source
UseChatOptionsOptions accepted by use chat.source
UseChatResultsource
UseChatScrollOptionsOptions for useChatScroll.source
UseChatScrollResultResult of useChatScroll.source
UseClipboardResultResult of useClipboard: transient copy feedback and a copy trigger.source
UseCompletionOptionsOptions accepted by use completion.source
UseCompletionResultResult returned from use completion.source
UseConversationChatOptionsuseConversationChat - the library primitive that binds a useChat session to conversation persistence, so application code does not need to duplicate the persistence effect.source
UseConversationChatResultResult returned by useConversationChat.source
UseConversationOptionsOptions for useConversation.source
UseConversationPersistenceStateAdditive persistence state returned by useConversation. It is kept separate from the original result interface so existing structural fixtures remain source-compatible.source
UseConversationResultResult of useConversation.source
UseConversationsActiveLoadStateAdditive active-record controls returned by useConversations.source
UseConversationsOptionsOptions for useConversations.source
UseConversationsPersistenceStateAdditive persistence state returned by useConversations.source
UseConversationsResultResult of useConversations.source
UseMessageBranchesResultResult of useMessageBranches, the message's regeneration variants.source
UseStreamingOptionsOptions accepted by use streaming.source
UseStreamingResultResult returned from use streaming.source
UseUploadOptionsOptions for useUpload.source
UseUploadResultResult of useUpload.source
UseVoiceInputOptionsOptions accepted by use voice input.source
UseVoiceInputResultResult returned from use voice input.source

Constants

NameDescriptionSource
useAgentCardRead the enclosing <AgentCard>'s state (name, avatar, messages, tool calls, status, thinking text, and the derived status presentation) so a custom AgentCard.* sub-part can render it. Throws when used outside an AgentCard.source
useAgentPickerRead the enclosing <AgentPicker>'s selection and open state (selected id, onSelect, open/setOpen, and the optional onCreate/onManage actions) from a custom sub-part. Throws when used outside an AgentPicker.source
useAppShellsource
useAttachmentPillRead the derived per-pill state provided by AttachmentPill.Root. Use it to build a custom pill part; throws if called outside an AttachmentPill.source
useAttachmentsPanelRead the panel state provided by AttachmentsPanel.Root (uploads + handlers). Use it to build a custom panel part; throws outside an AttachmentsPanel.source
useChatActionsRead the current ChatActions preset configuration from a composed ChatActions.* part. Throws outside ChatActions / ChatActions.Root.source
useChatContextRead the enclosing chat's shared state (messages, input, submit/stop, model, attachments, branches, theme). Provided by <Chat.Root> / <Chat>; throws when used outside one.source
useChatInputContextRead the enclosing <ChatInput> context; throws outside one.source
useChatSidebarItemRead the enclosing <ChatSidebar.Item>'s row state (the conversation summary, active flag, rename availability + startRename, remove, and the … menu open state) from a custom item sub-part. Throws outside a <ChatSidebar.Item>.source
useConversationsContextsource
useMessageContextRead the enclosing message's state (the message, role, streaming flag, parts, branch navigation, copy/edit/regenerate/feedback actions). Provided by <Message.Root>; throws when used outside a <Message>.source
useModelSelectorRead the current ModelSelector's selection + open state from a ModelSelector.* sub-part. Throws when called outside a ModelSelector / ModelSelector.Root.source
useReasoningRead the disclosure state provided by Reasoning.Root (text + open state). Use it to build a custom disclosure part; throws outside a Reasoning.source
useSourcesRead the state provided by Sources.Root (sources + click handler). Use it to build a custom row part; throws when called outside a Sources.source
useStepIndicatorRead the current StepIndicator's state from a StepIndicator.* sub-part. Throws when called outside a StepIndicator / StepIndicator.Root.source
useToolCallRead the current ToolCall's state from a ToolCall.* sub-part. Throws when called outside a ToolCall / ToolCall.Root.source

Deep imports

These import paths group focused functionality under this module. Each is a separate barrel; import only what you need.

veryfront/chat/ag-ui

TypeScript
import {  createAgUiChatEventDecoderState,  decodeAgUiSseChunk,  flushAgUiSseChunk,} from "veryfront/chat/ag-ui";

Components

NameDescriptionSource
DEFAULT_AG_UI_MAX_FRAME_CHARSDefault maximum characters retained for one AG-UI SSE frame.source

Functions

NameDescriptionSource
createAgUiChatEventDecoderStateState for create AG-UI chat event decoder.source
decodeAgUiSseChunkDecode AG-UI SSE chunk.source
flushAgUiSseChunkFlush AG-UI SSE chunk.source
mapAgUiRuntimeMessagesToChatUiMessagesMap AG-UI runtime messages to chat UI messages.source
parseSseEventEvent emitted for parse sse.source

Types

NameDescriptionSource
AgUiChatEventDecoderStateState for AG-UI chat event decoder.source
AgUiDecodedChunkPublic API contract for AG-UI decoded chunk.source
AgUiDecodedEventEvent emitted for AG-UI decoded.source
AgUiDecoderValidationModePublic API contract for AG-UI decoder validation mode.source
AgUiRunFinishedMetadataPublic API contract for AG-UI run finished metadata.source
AgUiRuntimeMessageMessage shape for AG-UI runtime.source
AgUiRuntimeToolCallPublic API contract for AG-UI runtime tool call.source
AgUiSnapshotMessageMessage shape for AG-UI snapshot.source
AgUiWireEventEvent emitted for AG-UI wire.source
AgUiWireEventNamePublic API contract for AG-UI wire event name.source
ParsedSseEventEvent emitted for parsed sse.source

Constants

NameDescriptionSource
getAgUiRunFinishedMetadataSchemaZod schema for get AG-UI run finished metadata.source
getAgUiSnapshotMessageSchemaZod schema for get AG-UI snapshot message.source
getAgUiSnapshotToolCallSchemaZod schema for get AG-UI snapshot tool call.source
getAgUiWireEventNameSchemaZod schema for get AG-UI wire event name.source
getAgUiWireEventSchemaZod schema for get AG-UI wire event.source

veryfront/chat/message-prep

TypeScript
import {  assertPreparedMessageBudget,  compactForStep,  compactHistoricalUiMessageToolInputs,} from "veryfront/chat/message-prep";

Components

NameDescriptionSource
DEFAULT_MESSAGE_PREP_LIMITSDefault limits for chat history preparation.source

Functions

NameDescriptionSource
assertPreparedMessageBudgetReject provider messages that exceed the shared prepared context budget.source
compactForStepCompact for step.source
compactHistoricalUiMessageToolInputsCompact large historical UI-message tool inputs after matching results are available.source
compactOldToolInputsCompact large historical tool-call inputs after matching results are available.source
compressTurnCompress turn.source
dedupeToolHistoryDedupe tool history.source
enforceTokenBudgetEnforce token budget.source
enforceTokenBudgetWithTurnCompressionEnforce token budget with turn compression.source
ensureToolCallInputsEnsure tool call inputs helper.source
estimateMessageTokenBreakdownEstimate token categories for provider, UI, or runtime messages.source
estimateOverheadEstimate overhead.source
estimateTokensEstimate tokens.source
isModelSupportedFileMediaTypeCheck whether the model supports the file media type.source
maskOldToolOutputsMask old tool outputs while retaining preceding-turn file evidence and resource results for follow-ups. Resource arrays, collection results, and objects with resource IDs retain up to 4,096 output characters; request, tool-call, trace, span, and correlation IDs alone do not qualify. Existing summary contracts take precedence.source
normalizeMessageFilePartMediaTypesNormalizes message file part media types.source
prepareProviderModelMessagesFromUiMessagesPrepare provider model messages from UI messages.source
repairToolPairsRepair tool pairs.source
rewriteUnsupportedFilePartsAsAnnotationsRewrite unsupported file parts as annotations.source
sanitizeProviderModelMessagesSanitize provider model messages.source
stripPendingToolPartsStrip pending tool parts.source

Types

NameDescriptionSource
HistoricalToolInputCompactionDiagnosticDiagnostic emitted when a completed historical tool input is compacted.source
HistoricalToolInputRetainedFieldField selector retained in a historical tool-input summary.source
HistoricalToolInputRetentionOptionsOptions for historical tool-input compaction.source
HistoricalToolInputRetentionPolicyPolicy for compacting a completed historical tool-call input.source
HistoricalToolInputRetentionPolicyResolverResolves the retention policy for a completed historical tool input.source
MessagePrepLimitsTunable limits used while preparing chat history for model context.source
MessageTokenBreakdownApproximate token categories for context diagnostics.source
PrepareProviderModelMessagesFromUiMessagesOptionsOptions accepted by prepare provider model messages from UI messages.source

veryfront/chat/protocol

Canonical chat message and stream protocol for Veryfront chat surfaces. These types describe the framework-owned message parts and stream events used by AG-UI-aligned chat clients, hooks, and adapters.

TypeScript
import type { ChatDataPart, ChatDynamicToolPart, ChatFilePart } from "veryfront/chat/protocol";

Types

NameDescriptionSource
ChatDataPartPublic API contract for chat data part.source
ChatDynamicToolPartPublic API contract for chat dynamic tool part.source
ChatFilePartChat message part that carries an uploaded file or image attachment.source
ChatFinishReasonPublic API contract for chat finish reason.source
ChatMessageMessage shape for chat.source
ChatMessageMetadataPublic API contract for chat message metadata.source
ChatMessageMetadataUsagePublic API contract for chat message metadata usage.source
ChatMessagePartPublic API contract for chat message part.source
ChatPartStateCanonical chat message and stream protocol for Veryfront chat surfaces.source
ChatReasoningPartChat message part that carries reasoning text.source
ChatSourceDocumentPartChat message part that carries a document citation source.source
ChatSourceUrlPartChat message part that carries a URL citation source.source
ChatStepPartPublic API contract for chat step part.source
ChatStreamEventEvent emitted for chat stream.source
ChatTextPartChat message part that carries text.source
ChatToolPartPublic API contract for chat tool part.source
ChatToolResultPartChat message part that carries a tool result.source
ChatToolStateState for chat tool.source
ChatUiMessageChunkPublic API contract for chat UI message chunk.source
ChildRunAuditPublic API contract for child run audit.source
ChildRunAuditToolCallPublic API contract for child run audit tool call.source
ChildRunAuditToolResultResult returned from child run audit tool.source

veryfront/chat/types

TypeScript
import { buildDataFileAnnotation, isImageFile, isTextPreviewFile } from "veryfront/chat/types";

Functions

NameDescriptionSource
buildDataFileAnnotationBuilds data file annotation.source
isImageFileCheck whether a file is an image.source
isTextPreviewFileCheck whether a file supports text preview.source
isValidImageFileCheck whether a file is a supported image upload.source
normalizeInlineAttachmentMediaTypeNormalizes inline attachment media type.source

Types

NameDescriptionSource
ChatAssistantContentPartPublic API contract for chat assistant content part.source
ChatAssistantMessageMessage shape for chat assistant.source
ChatDataUiPartChat UI part that carries custom data chunks.source
ChatDynamicToolUiPartTool UI part for a runtime-selected tool name.source
ChatFileUiPartPublic API contract for chat file UI part.source
ChatMessageMetadataPublic API contract for chat message metadata.source
ChatMessageMetadataUsagePublic API contract for chat message metadata usage.source
ChatModelFilePartPublic API contract for chat model file part.source
ChatModelReasoningPartProvider model message part that carries reasoning text.source
ChatModelTextPartProvider model message part that carries text.source
ChatNamedToolUiPartTool UI part keyed by a static tool type.source
ChatReasoningUiPartPublic API contract for chat reasoning UI part.source
ChatRequestContextContext for chat request.source
ChatRuntimeOverridesPublic API contract for chat runtime overrides.source
ChatSourceDocumentUiPartPublic API contract for chat source document UI part.source
ChatSourceUrlUiPartPublic API contract for chat source URL UI part.source
ChatStepStartUiPartPublic API contract for chat step start UI part.source
ChatSystemMessageMessage shape for chat system.source
ChatTextUiPartPublic API contract for chat text UI part.source
ChatToolCallPartProvider model message part that carries a tool call.source
ChatToolMessageMessage shape for chat tool.source
ChatToolPartStateState for chat tool part.source
ChatToolResultOutputOutput from chat tool result.source
ChatToolResultPartProvider model message part that carries a tool result.source
ChatUiMessageMessage shape for chat UI.source
ChatUiMessageChunkPublic API contract for chat UI message chunk.source
ChatUiMessagePartPublic API contract for chat UI message part.source
ChatUiMessageRolePublic API contract for chat UI message role.source
ChatUserContentPartPublic API contract for chat user content part.source
ChatUserMessageMessage shape for chat user.source
ChildRunAuditPublic API contract for child run audit.source
ChildRunAuditToolCallPublic API contract for child run audit tool call.source
ChildRunAuditToolResultResult returned from child run audit tool.source
DurableRootRunDescriptorPublic API contract for durable root run descriptor.source
FileUIPartWithUploadFile UI part enriched with upload metadata.source
MessageMetadataPublic API contract for chat message metadata.source
ProjectFilePublic API contract for project file.source
ProjectFileListItemPublic API contract for project file list item.source
ProviderModelMessageMessage shape for provider model.source
UploadedFileReferencePublic API contract for uploaded file reference.source

Constants

NameDescriptionSource
getChatRequestContextSchemaZod schema for get chat request context.source
getChatToolPartStateSchemaZod schema for get chat tool part state.source
getChatUiMessagePartSchemaZod schema for get chat UI message part.source
getChatUiMessageRoleSchemaZod schema for get chat UI message role.source
getChatUiMessageSchemaZod schema for get chat UI message.source
getChatUiMessagesSchemaZod schema for get chat UI messages.source
getMessageMetadataSchemaZod schema for get message metadata.source
imageFileTypesImage media types that chat uploads can display natively.source
textFileExtensionsFile extensions that chat uploads can inline as text.source

veryfront/chat/uploads

Chat upload handler: the server side of <Chat>'s batteries-included attachments. Mount it at app/api/uploads/route.ts (the same endpoint the composer POSTs to) and files "just work": stored on the local disk in dev, on Veryfront Cloud (or a BlobStorage you pass) once deployed. ts // app/api/uploads/route.ts import { createChatUploadHandler } from "veryfront/chat/uploads"; function authorize(request: Request) { const token = Deno.env.get("UPLOAD_TOKEN"); return Boolean(token && request.headers.get("authorization") === `Bearer ${token}`); } export const { POST, GET, DELETE } = createChatUploadHandler({ authorize }); POST stores the multipart file field and returns { id, url, name, mediaType, size }. The composer sends that url as a file message part, which the runtime fetches, so the URL must be reachable by the runtime (true for local dev, where GET streams the file back from the same origin).

TypeScript
import { createChatUploadHandler, resolveStorage } from "veryfront/chat/uploads";

Functions

NameDescriptionSource
createChatUploadHandlerBuild { POST, GET, DELETE } route handlers for chat attachments. Auto-selects local disk storage in dev and Veryfront Cloud once deployed, or the storage you provide. Every route fails closed unless an authorizer returns literal true or unauthenticated access is explicitly enabled. Multipart request bodies and file bytes are bounded independently. GET without an id (the listing used by useAttachments on mount) responds 400 unless allowListing: true opts in. Enable it only when every authorized caller may access every stored upload. DELETE ?id= removes the file from storage.source
resolveStorageSelect the blob backend for chat uploads: an explicitly configured storage wins, then Veryfront Cloud once deployed, then local disk.source

Types

NameDescriptionSource
ChatUploadAuthorizationResultResult returned by a chat upload-route authorizer.source
ChatUploadAuthorizeAuthorizes one chat upload-route request.source
ChatUploadHandlerConfigConfiguration for createChatUploadHandler.source