Variable: MessageRole
@providerprotocol/ai / @providerprotocol/ai / MessageRole
Variable: MessageRole
Section titled “Variable: MessageRole”
constMessageRole:object
Defined in: src/types/messages.ts:52
Message role/type constants.
Use these constants instead of raw strings for type-safe message handling:
Type Declaration
Section titled “Type Declaration”Assistant
Section titled “Assistant”
readonlyAssistant:"assistant"='assistant'
Assistant/model response
ToolResult
Section titled “ToolResult”
readonlyToolResult:"tool_result"='tool_result'
Tool execution result
readonlyUser:"user"='user'
User message
Example
Section titled “Example”import { MessageRole, isUserMessage } from 'upp';
if (message.type === MessageRole.User) { console.log('User said:', message.text);} else if (message.type === MessageRole.Assistant) { console.log('Assistant replied:', message.text);}