message
Module: @vibex/core/message
Message Types - AI SDK v6 Compatible
VibeX adopts a parts-based message format aligned with AI SDK v6. This provides structured content types for text, tools, reasoning, and artifacts.
Interfaces
TextPart
View sourceMessage Types - AI SDK v6 Compatible
VibeX adopts a parts-based message format aligned with AI SDK v6. This provides structured content types for text, tools, reasoning, and artifacts.
Properties:
| Name | Type | Description |
|---|---|---|
type | "text" | |
text | string |
ToolCallPart
View sourceTool call part - when an agent invokes a tool
Properties:
| Name | Type | Description |
|---|---|---|
type | "tool-call" | |
toolCallId | string | |
toolName | string | |
args | Record<string, unknown> | |
status | "pending" | "running" | "completed" | "failed" | "pending-approval" | (optional) |
ToolResultPart
View sourceTool result part - the output from a tool
Properties:
| Name | Type | Description |
|---|---|---|
type | "tool-result" | |
toolCallId | string | |
toolName | string | |
result | unknown | |
isError | boolean | (optional) |
ReasoningPart
View sourceReasoning part - for chain-of-thought or thinking
Properties:
| Name | Type | Description |
|---|---|---|
type | "reasoning" | |
text | string |
ArtifactPart
View sourceArtifact reference part - VibeX-specific for document/file references
Properties:
| 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) |
PlanUpdatePart
View sourcePlan update part - VibeX-specific for plan/task changes
Properties:
| Name | Type | Description |
|---|---|---|
type | "plan-update" | |
planId | string | |
action | "created" | "updated" | "completed" | "failed" | |
summary | string | (optional) |
tasksAffected | string[] | (optional) |
FilePart
View sourceFile part - for file attachments
Properties:
| Name | Type | Description |
|---|---|---|
type | "file" | |
fileId | string | |
filename | string | |
mimeType | string | |
url | string | (optional) |
size | number | (optional) |
StepStartPart
View sourceStep start part - marks the beginning of a multi-step process
Properties:
| Name | Type | Description |
|---|---|---|
type | "step-start" | |
stepId | string | |
stepName | string | |
agentName | string | (optional) |
ModelMessage
View sourceModel message - minimal format for LLM APIs (AI SDK CoreMessage compatible)
Properties:
| Name | Type | Description |
|---|---|---|
role | MessageRole | |
content | string | XMessagePart[] |
XMessage
View sourceVibeX message - full server-side message with metadata and parts
This is the canonical message format used throughout VibeX.
It supports both legacy content and new parts format.
Properties:
| Name | Type | Description |
|---|---|---|
id | string | Unique message identifier (optional) |
role | MessageRole | Role of the message sender |
parts | XMessagePart[] | Message parts - structured content (v6 format) |
Preferred over content for new code. (optional) | ||
content | string | unknown[] | Legacy content field (optional) |
metadata | object | Message metadata (optional) |
Types
XMessagePart
View sourceUnion of all message part types
type XMessagePart = | TextPart
| ToolCallPart
| ToolResultPart
| ReasoningPart
| ArtifactPart
| PlanUpdatePart
| FilePart
| StepStartPartMessageRole
View sourceMessage role types
type MessageRole = "system" | "user" | "assistant" | "tool"Message
View sourceAlias for XMessage
type Message = XMessageChatStatus
View sourceGranular message/chat status
type ChatStatus = | "idle" // No activity
| "submitted" // Request sent, waiting for response
| "streaming" // Actively receiving response
| "awaiting-approval" // Tool call needs human approval
| "error"Functions
getTextFromParts
View sourceExtract text content from message parts
function getTextFromParts(parts: XMessagePart[]): stringParameters:
| Name | Type | Description |
|---|---|---|
parts | XMessagePart[] |
createTextMessage
View sourceCreate a simple text message
function createTextMessage(role: MessageRole, text: string, metadata?: XMessage["metadata"]): XMessageParameters:
| Name | Type | Description |
|---|---|---|
role | MessageRole | |
text | string | |
metadata | XMessage["metadata"] (optional) |
hasPendingApproval
View sourceCheck if message has pending tool approvals
function hasPendingApproval(message: XMessage): booleanParameters:
| Name | Type | Description |
|---|---|---|
message | XMessage |
getToolCalls
View sourceGet all tool calls from a message
function getToolCalls(message: XMessage): ToolCallPart[]Parameters:
| Name | Type | Description |
|---|---|---|
message | XMessage |
getArtifacts
View sourceGet all artifacts from a message
function getArtifacts(message: XMessage): ArtifactPart[]Parameters:
| Name | Type | Description |
|---|---|---|
message | XMessage |
contentToParts
View sourceConvert legacy content to parts format
function contentToParts(content: string | unknown[] | undefined): XMessagePart[]Parameters:
| Name | Type | Description |
|---|---|---|
content | string | unknown[] | undefined |
normalizeMessage
View sourceNormalize a message to always have parts
function normalizeMessage(message: XMessage): XMessageParameters:
| Name | Type | Description |
|---|---|---|
message | XMessage |