shipdeck
Version:
Ship MVPs in 48 hours. Fix bugs in 30 seconds. The command deck for developers who ship.
156 lines (130 loc) • 3.72 kB
JavaScript
/**
* VisualStoryteller Agent
* Creates compelling visual narratives and infographics
*/
const BaseAgent = require('./base-agent');
const { AnthropicClient } = require('../anthropic/client');
/**
* VisualStoryteller - Creates compelling visual narratives and infographics
*/
class VisualStorytellerAgent extends BaseAgent {
constructor(config = {}) {
super('VisualStorytellerAgent', {
...config,
description: 'Creates compelling visual narratives and infographics',
version: '1.0.0'
});
this.capabilities = ["storytelling","infographics","presentations","data-viz"];
this.anthropicClient = config.anthropicClient || new AnthropicClient();
}
/**
* Get agent capabilities
* @returns {Array} List of capabilities
*/
getCapabilities() {
return this.capabilities;
}
/**
* Get system prompt for the agent
* @returns {string} System prompt
*/
getSystemPrompt() {
return `You are VisualStorytellerAgent, an AI agent specialized in storytelling, infographics, presentations, data-viz.
Your core responsibilities:
- storytelling
- infographics
- presentations
- data-viz
Always provide practical, production-ready solutions.`;
}
/**
* Execute agent task
* @param {Object} task - Task to execute
* @param {Object} context - Execution context
* @returns {Promise<Object>} Execution result
*/
async execute(task, context = {}) {
try {
this.validateTask(task);
const systemPrompt = this.getSystemPrompt();
const userPrompt = this.createPrompt(task, context);
const response = await this.anthropicClient.createMessage(
`${systemPrompt}
${userPrompt}`,
{
maxTokens: 4096,
temperature: 0.7
}
);
return this.parseResponse(response, task.type);
} catch (error) {
this.emit('error', error);
throw new Error(`VisualStorytellerAgent execution failed: ${error.message}`);
}
}
/**
* Create prompt for the task
* @param {Object} task - Task object
* @param {Object} context - Context object
* @returns {string} Generated prompt
*/
createPrompt(task, context) {
const { type, description, requirements = [] } = task;
return `Task Type: ${type}
Description: ${description}
Requirements: ${requirements.join(', ')}
Please provide a comprehensive solution.`;
}
/**
* Parse agent response
* @param {Object} response - API response
* @param {string} type - Task type
* @returns {Object} Parsed result
*/
parseResponse(response, type) {
const content = response.content?.[0]?.text || '';
return {
success: true,
type: type,
content: content,
timestamp: new Date().toISOString()
};
}
/**
* createInfographics implementation
* @param {Object} params - Method parameters
* @returns {Promise<Object>} Method result
*/
async createInfographics(params = {}) {
const task = {
type: 'createInfographics',
...params
};
return this.execute(task);
}
/**
* buildPresentations implementation
* @param {Object} params - Method parameters
* @returns {Promise<Object>} Method result
*/
async buildPresentations(params = {}) {
const task = {
type: 'buildPresentations',
...params
};
return this.execute(task);
}
/**
* visualizeData implementation
* @param {Object} params - Method parameters
* @returns {Promise<Object>} Method result
*/
async visualizeData(params = {}) {
const task = {
type: 'visualizeData',
...params
};
return this.execute(task);
}
}
module.exports = VisualStorytellerAgent;