Skip to Content

types

Module: @vibex/react/types

VibeX React Types

Client-side message types optimized for UI rendering. These abstract away the underlying AI SDK implementation.

Aligned with AI SDK v6’s parts-based message format.

Interfaces

UITextPart

View source

UI-specific message part types that extend core parts

Properties:

NameTypeDescription
type"text"
textstring

UIToolCallPart

View source

Properties:

NameTypeDescription
type"tool-call"
toolCallIdstring
toolNamestring
argsRecord<string, unknown>
status"pending" | "running" | "completed" | "failed" | "pending-approval"(optional)
displayNamestringUI-specific: Display name for the tool (optional)

UIToolResultPart

View source

Properties:

NameTypeDescription
type"tool-result"
toolCallIdstring
toolNamestring
resultunknown
isErrorboolean(optional)
formattedResultstringUI-specific: Formatted result for display (optional)

UIArtifactPart

View source

Properties:

NameTypeDescription
type"artifact"
artifactIdstring
titlestring(optional)
versionnumber(optional)
artifactType"document" | "code" | "data" | "image" | "file"(optional)
previewstring(optional)
action"created" | "updated" | "referenced"(optional)
isExpandedbooleanUI-specific: Whether the artifact is expanded in view (optional)

UIReasoningPart

View source

Properties:

NameTypeDescription
type"reasoning"
textstring
isCollapsedbooleanUI-specific: Whether reasoning is collapsed (optional)

XChatMessage

View source

A message in a VibeX chat conversation (client-side)

This is the UI-optimized type used by React hooks and components. Supports both legacy content and new parts format.

Properties:

NameTypeDescription
idstringUnique identifier for the message
role"user" | "assistant" | "system"The role of who sent the message
partsXChatPart[]Message parts - structured content (v6 format)
Use this for rendering rich content in the UI. (optional)
contentstringText content of the message (convenience accessor)
Extracted from parts or legacy content.
createdAtDateWhen the message was created (optional)
agentNamestringName of the agent that generated this message (optional)
metadataRecord<string, unknown>Optional metadata attached to the message (optional)

CreateXMessage

View source

Options for creating a new message

Properties:

NameTypeDescription
role"user" | "assistant" | "system"The role of who sent the message
contentstringThe text content of the message
partsXChatPart[]Optional parts for structured content (optional)
metadataRecord<string, unknown>Optional metadata attached to the message (optional)

XChatState

View source

Chat state and controls returned by useXChat

Properties:

NameTypeDescription
messagesXChatMessage[]The current messages in the conversation
inputstringThe current input value
setInput(input: string) => voidSet the input value
statusXChatStatusGranular status of the chat
Replaces legacy isLoading boolean
isLoadingbooleanWhether a response is currently being generated
errorErrorAny error that occurred (optional)
append(message: CreateXMessage) => Promise<void>Append a new message and trigger a response
reload() => Promise<void>Regenerate the last assistant message
stop() => voidStop the current generation
setMessages(messages: XChatMessage[]) => voidSet the messages directly
approveToolCall(toolCallId: string, approved: boolean) => Promise<void>Approve a pending tool call
Only available when status is “awaiting-approval” (optional)

Types

XChatPart

View source

Union of all UI message part types

type XChatPart = | UITextPart | UIToolCallPart | UIToolResultPart | UIArtifactPart | UIReasoningPart

XChatStatus

View source

Granular chat status (aligned with AI SDK v6)

type XChatStatus = | "idle" // No activity | "submitted" // Request sent, waiting for response | "streaming" // Actively receiving response | "awaiting-approval" // Tool call needs human approval | "error"

Functions

getMessageText

View source

Extract text content from a XChatMessage

function getMessageText(message: XChatMessage): string

Parameters:

NameTypeDescription
messageXChatMessage

messageNeedsApproval

View source

Check if a message has pending tool approvals

function messageNeedsApproval(message: XChatMessage): boolean

Parameters:

NameTypeDescription
messageXChatMessage

getPendingApprovals

View source

Get all tool calls from a message that need approval

function getPendingApprovals(message: XChatMessage): UIToolCallPart[]

Parameters:

NameTypeDescription
messageXChatMessage

createUserMessage

View source

Create a simple user message

function createUserMessage(text: string): CreateXMessage

Parameters:

NameTypeDescription
textstring

isStatusLoading

View source

Check if status indicates loading

function isStatusLoading(status: XChatStatus): boolean

Parameters:

NameTypeDescription
statusXChatStatus