claude-expert-workflow-mcp
Version:
Production-ready MCP server for AI-powered product development consultation through specialized expert roles. Enterprise-grade with memory management, monitoring, and Claude Code integration.
68 lines • 2.6 kB
JavaScript
import { logger } from '../utils/logger';
export class ConversationManager {
constructor() {
this.conversations = new Map();
}
generateConversationId() {
return `conv_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
}
createConversation(id) {
const conversationId = id || this.generateConversationId();
const conversation = {
id: conversationId,
messages: [],
completedTopics: [],
createdAt: new Date(),
updatedAt: new Date()
};
this.conversations.set(conversationId, conversation);
logger.debug(`Created conversation: ${conversationId}`);
return conversationId;
}
getConversation(id) {
return this.conversations.get(id);
}
addMessage(conversationId, role, content) {
const conversation = this.conversations.get(conversationId);
if (!conversation) {
throw new Error(`Conversation ${conversationId} not found`);
}
const message = {
role,
content,
timestamp: new Date()
};
conversation.messages.push(message);
conversation.updatedAt = new Date();
logger.debug(`Added message to conversation ${conversationId}: ${role}`);
}
getConversationHistory(conversationId) {
const conversation = this.conversations.get(conversationId);
return conversation ? conversation.messages : [];
}
updateTopic(conversationId, topic) {
const conversation = this.conversations.get(conversationId);
if (!conversation) {
throw new Error(`Conversation ${conversationId} not found`);
}
conversation.currentTopic = topic;
conversation.updatedAt = new Date();
}
markTopicComplete(conversationId, topic) {
const conversation = this.conversations.get(conversationId);
if (!conversation) {
throw new Error(`Conversation ${conversationId} not found`);
}
if (!conversation.completedTopics.includes(topic)) {
conversation.completedTopics.push(topic);
conversation.updatedAt = new Date();
logger.debug(`Marked topic complete: ${topic} for conversation ${conversationId}`);
}
}
getCompletedTopics(conversationId) {
const conversation = this.conversations.get(conversationId);
return conversation ? conversation.completedTopics : [];
}
}
export const conversationManager = new ConversationManager();
//# sourceMappingURL=conversationManager.js.map