export function getLastAssistantText(messages) {
    const lastAssistant = messages
        .slice()
        .reverse()
        .find((message) => {
        if (message.role !== 'assistant')
            return false;
        const assistantMessage = message;
        return !(assistantMessage.stopReason === 'aborted' && assistantMessage.content.length === 0);
    });
    if (!lastAssistant) {
        return undefined;
    }
    let text = '';
    for (const content of lastAssistant.content) {
        if (content.type === 'text') {
            text += content.text;
        }
    }
    return text.trim() || undefined;
}
//# sourceMappingURL=assistant-text.js.map