* Send a message and stream the response. * Supports both simple string content and multimodal content (images, audio, video, documents). * * @param content - The message content. Can be: * - A simple string for text-only messages * - A MultimodalContent object with content array
(
content: string | MultimodalContent,
body?: Record<string, any>,
)
| 769 | * ``` |
| 770 | */ |
| 771 | async sendMessage( |
| 772 | content: string | MultimodalContent, |
| 773 | body?: Record<string, any>, |
| 774 | ): Promise<void> { |
| 775 | this.mountDevtools() |
| 776 | const emptyMessage = typeof content === 'string' && !content.trim() |
| 777 | if (emptyMessage || this.isLoading) { |
| 778 | return |
| 779 | } |
| 780 | // Normalize input to extract content, id, and validate |
| 781 | const normalizedContent = this.normalizeMessageInput(content) |
| 782 | |
| 783 | // Store the per-message body for use in streamResponse |
| 784 | this.pendingMessageBody = body |
| 785 | |
| 786 | // Add user message via processor |
| 787 | const userMessage = this.processor.addUserMessage( |
| 788 | normalizedContent.content, |
| 789 | normalizedContent.id, |
| 790 | ) |
| 791 | this.events.messageSent(userMessage.id, normalizedContent.content) |
| 792 | |
| 793 | await this.streamResponse() |
| 794 | } |
| 795 | |
| 796 | /** |
| 797 | * Normalize the message input to extract content and optional id. |
nothing calls this directly
no test coverage detected