import { aiProviderManager } from '../ai-providers/index.js';
export const testAgent = {
    async execute(input) {
        return {
            message: 'Hello from test agent!',
            input: input,
            timestamp: new Date().toISOString(),
            status: 'success'
        };
    }
};
export const echoAgent = {
    async execute(input) {
        return {
            echo: input,
            timestamp: new Date().toISOString()
        };
    }
};
export const gpt4Assistant = {
    async execute(input) {
        const { prompt, systemPrompt, temperature, maxTokens } = input.data || {};
        if (!prompt) {
            throw new Error('prompt is required');
        }
        const messages = [];
        if (systemPrompt) {
            messages.push({ role: 'system', content: systemPrompt });
        }
        messages.push({ role: 'user', content: prompt });
        const response = await aiProviderManager.complete({
            model: 'gpt-4',
            messages,
            temperature: temperature ?? 0.7,
            maxTokens: maxTokens ?? 1000
        });
        return {
            result: response.content,
            model: response.model,
            usage: response.usage,
            cost: await aiProviderManager.getProvider('openai')?.estimateCost({
                model: 'gpt-4',
                messages
            })
        };
    }
};
export const claudeAssistant = {
    async execute(input) {
        const { prompt, systemPrompt, temperature, maxTokens } = input.data || {};
        if (!prompt) {
            throw new Error('prompt is required');
        }
        const messages = [];
        if (systemPrompt) {
            messages.push({ role: 'system', content: systemPrompt });
        }
        messages.push({ role: 'user', content: prompt });
        const response = await aiProviderManager.complete({
            model: 'claude-3-5-sonnet-20241022',
            messages,
            temperature: temperature ?? 0.7,
            maxTokens: maxTokens ?? 1000
        });
        return {
            result: response.content,
            model: response.model,
            usage: response.usage,
            cost: await aiProviderManager.getProvider('anthropic')?.estimateCost({
                model: 'claude-3-5-sonnet-20241022',
                messages
            })
        };
    }
};
export const sentimentAnalyzer = {
    async execute(input) {
        const { texts } = input.data || {};
        if (!texts || !Array.isArray(texts)) {
            throw new Error('texts array is required');
        }
        const results = [];
        for (const text of texts) {
            const response = await aiProviderManager.complete({
                model: 'gpt-3.5-turbo',
                messages: [
                    {
                        role: 'system',
                        content: 'You are a sentiment analyzer. Respond with ONLY one word: positive, negative, or neutral.'
                    },
                    { role: 'user', content: text }
                ],
                temperature: 0.3,
                maxTokens: 10
            });
            results.push({
                text,
                sentiment: response.content.toLowerCase().trim(),
                confidence: 0.95
            });
        }
        return {
            results,
            model: 'gpt-3.5-turbo',
            totalAnalyzed: texts.length
        };
    }
};
export const textSummarizer = {
    async execute(input) {
        const { text, maxLength } = input.data || {};
        if (!text) {
            throw new Error('text is required');
        }
        const response = await aiProviderManager.complete({
            model: 'gpt-4',
            messages: [
                {
                    role: 'system',
                    content: `Summarize the following text in ${maxLength || 100} words or less.`
                },
                { role: 'user', content: text }
            ],
            temperature: 0.5,
            maxTokens: (maxLength || 100) * 2
        });
        return {
            original_length: text.length,
            summary: response.content,
            summary_length: response.content.length,
            compression_ratio: (response.content.length / text.length * 100).toFixed(2) + '%',
            usage: response.usage
        };
    }
};
export const researchAgent = {
    async execute(input) {
        const { topic } = input.data || {};
        if (!topic) {
            throw new Error('topic is required');
        }
        const questionsResponse = await aiProviderManager.complete({
            model: 'gpt-4',
            messages: [
                {
                    role: 'system',
                    content: 'Generate 3 research questions about this topic. Return only the questions, one per line.'
                },
                { role: 'user', content: topic }
            ],
            temperature: 0.7,
            maxTokens: 200
        });
        const questions = questionsResponse.content.split('\n').filter(q => q.trim());
        const answers = [];
        for (const question of questions) {
            const answerResponse = await aiProviderManager.complete({
                model: 'gpt-4',
                messages: [
                    { role: 'system', content: 'Answer this research question concisely.' },
                    { role: 'user', content: question }
                ],
                temperature: 0.7,
                maxTokens: 300
            });
            answers.push({
                question,
                answer: answerResponse.content
            });
        }
        const synthesisResponse = await aiProviderManager.complete({
            model: 'gpt-4',
            messages: [
                {
                    role: 'system',
                    content: 'Synthesize these research findings into a cohesive summary.'
                },
                {
                    role: 'user',
                    content: JSON.stringify(answers, null, 2)
                }
            ],
            temperature: 0.7,
            maxTokens: 500
        });
        return {
            topic,
            questions,
            answers,
            synthesis: synthesisResponse.content,
            totalSteps: 3
        };
    }
};
export const agents = {
    'test-agent': testAgent,
    'echo-agent': echoAgent,
    'gpt4-assistant': gpt4Assistant,
    'claude-assistant': claudeAssistant,
    'sentiment-analyzer': sentimentAnalyzer,
    'text-summarizer': textSummarizer,
    'research-agent': researchAgent
};
export function getAgent(agentId) {
    return agents[agentId];
}
export function listAgents() {
    return Object.keys(agents);
}
//# sourceMappingURL=definitions.js.map