/** * March Agent SDK - Conversation Message * Port of Python march_agent/conversation_message.py */ import type { ConversationMessageData } from './types.js' /** * Represents a message from conversation history. */ export class ConversationMessage { readonly id: string readonly conversationId: string readonly role: 'user' | 'assistant' | 'system' readonly content: string readonly from?: string readonly to?: string readonly createdAt: Date readonly metadata?: Record constructor(data: ConversationMessageData) { this.id = data.id this.conversationId = data.conversationId this.role = data.role this.content = data.content this.from = data.from this.to = data.to this.createdAt = new Date(data.createdAt) this.metadata = data.metadata } /** * Create from API response */ static fromApiResponse(data: Record): ConversationMessage { return new ConversationMessage({ id: data.id as string, conversationId: data.conversation_id as string, role: data.role as 'user' | 'assistant' | 'system', content: data.content as string, from: data.from as string | undefined, to: data.to as string | undefined, createdAt: data.created_at as string, metadata: data.metadata as Record | undefined, }) } /** * Check if this is a user message */ isUser(): boolean { return this.role === 'user' } /** * Check if this is an assistant message */ isAssistant(): boolean { return this.role === 'assistant' } }