import { coerceMessageContent } from './helpers';
export const buildOllamaMessages = (agent, input) => {
    const messages = [];
    const instructions = agent.options.instructions;
    if (typeof instructions === 'string' && instructions.trim().length > 0) {
        messages.push({ role: 'system', content: instructions.trim() });
    }
    for (const item of input.messages) {
        const role = item.role;
        if (role !== 'user' && role !== 'assistant' && role !== 'system') {
            continue;
        }
        const content = coerceMessageContent(item);
        if (!content) {
            continue;
        }
        messages.push({
            role,
            content
        });
    }
    if (messages.length === 0) {
        throw new Error('Ollama provider requires at least one message in the conversation');
    }
    return messages;
};
