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 sourceUI-specific message part types that extend core parts
Properties:
| Name | Type | Description |
|---|---|---|
type | "text" | |
text | string |
UIToolCallPart
View sourceProperties:
| Name | Type | Description |
|---|---|---|
type | "tool-call" | |
toolCallId | string | |
toolName | string | |
args | Record<string, unknown> | |
status | "pending" | "running" | "completed" | "failed" | "pending-approval" | (optional) |
displayName | string | UI-specific: Display name for the tool (optional) |
UIToolResultPart
View sourceProperties:
| Name | Type | Description |
|---|---|---|
type | "tool-result" | |
toolCallId | string | |
toolName | string | |
result | unknown | |
isError | boolean | (optional) |
formattedResult | string | UI-specific: Formatted result for display (optional) |
UIArtifactPart
View sourceProperties:
| Name | Type | Description |
|---|---|---|
type | "artifact" | |
artifactId | string | |
title | string | (optional) |
version | number | (optional) |
artifactType | "document" | "code" | "data" | "image" | "file" | (optional) |
preview | string | (optional) |
action | "created" | "updated" | "referenced" | (optional) |
isExpanded | boolean | UI-specific: Whether the artifact is expanded in view (optional) |
UIReasoningPart
View sourceProperties:
| Name | Type | Description |
|---|---|---|
type | "reasoning" | |
text | string | |
isCollapsed | boolean | UI-specific: Whether reasoning is collapsed (optional) |
XChatMessage
View sourceA 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:
| Name | Type | Description |
|---|---|---|
id | string | Unique identifier for the message |
role | "user" | "assistant" | "system" | The role of who sent the message |
parts | XChatPart[] | Message parts - structured content (v6 format) |
| Use this for rendering rich content in the UI. (optional) | ||
content | string | Text content of the message (convenience accessor) |
| Extracted from parts or legacy content. | ||
createdAt | Date | When the message was created (optional) |
agentName | string | Name of the agent that generated this message (optional) |
metadata | Record<string, unknown> | Optional metadata attached to the message (optional) |
CreateXMessage
View sourceOptions for creating a new message
Properties:
| Name | Type | Description |
|---|---|---|
role | "user" | "assistant" | "system" | The role of who sent the message |
content | string | The text content of the message |
parts | XChatPart[] | Optional parts for structured content (optional) |
metadata | Record<string, unknown> | Optional metadata attached to the message (optional) |
XChatState
View sourceChat state and controls returned by useXChat
Properties:
| Name | Type | Description |
|---|---|---|
messages | XChatMessage[] | The current messages in the conversation |
input | string | The current input value |
setInput | (input: string) => void | Set the input value |
status | XChatStatus | Granular status of the chat |
Replaces legacy isLoading boolean | ||
isLoading | boolean | Whether a response is currently being generated |
error | Error | Any 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 | () => void | Stop the current generation |
setMessages | (messages: XChatMessage[]) => void | Set 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 sourceUnion of all UI message part types
type XChatPart = | UITextPart
| UIToolCallPart
| UIToolResultPart
| UIArtifactPart
| UIReasoningPartXChatStatus
View sourceGranular 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 sourceExtract text content from a XChatMessage
function getMessageText(message: XChatMessage): stringParameters:
| Name | Type | Description |
|---|---|---|
message | XChatMessage |
messageNeedsApproval
View sourceCheck if a message has pending tool approvals
function messageNeedsApproval(message: XChatMessage): booleanParameters:
| Name | Type | Description |
|---|---|---|
message | XChatMessage |
getPendingApprovals
View sourceGet all tool calls from a message that need approval
function getPendingApprovals(message: XChatMessage): UIToolCallPart[]Parameters:
| Name | Type | Description |
|---|---|---|
message | XChatMessage |
createUserMessage
View sourceCreate a simple user message
function createUserMessage(text: string): CreateXMessageParameters:
| Name | Type | Description |
|---|---|---|
text | string |
isStatusLoading
View sourceCheck if status indicates loading
function isStatusLoading(status: XChatStatus): booleanParameters:
| Name | Type | Description |
|---|---|---|
status | XChatStatus |