sendMessage method
Send a user message and receive assistant response(s).
Returns the final assistant message. Tool use and intermediate messages are delivered via the messages stream.
Implementation
Future<Message> sendMessage(String text) async {
_ensureActive();
final userMsg = Message.user(text);
_history.add(userMsg);
_messageController.add(userMsg);
// In a real implementation this would call the API in a loop,
// processing tool use until the assistant produces a final response.
// Placeholder: return an empty assistant message.
final assistantMsg = Message.assistant('');
_history.add(assistantMsg);
_messageController.add(assistantMsg);
_config.onMessage?.call(assistantMsg);
return assistantMsg;
}