UNPKG

vibe-coder-mcp

Version:

Production-ready MCP server with complete agent integration, multi-transport support, and comprehensive development automation tools for AI-assisted workflows.

50 lines (49 loc) 1.85 kB
import logger from '../../logger.js'; const sessionHistories = new Map(); const MAX_HISTORY_LENGTH = 10; export function addInteraction(sessionId, historyEntry) { if (!sessionId || typeof sessionId !== 'string') { logger.warn('Attempted to add interaction without a valid session ID.'); return; } if (!sessionHistories.has(sessionId)) { sessionHistories.set(sessionId, []); } const history = sessionHistories.get(sessionId); history.push(historyEntry); if (history.length > MAX_HISTORY_LENGTH) { history.shift(); logger.debug(`History limit reached for session ${sessionId}. Removed oldest entry.`); } logger.debug(`Added interaction to history for session ${sessionId}. History length: ${history.length}`); } export function getLastInteraction(sessionId) { if (!sessionId || typeof sessionId !== 'string') return undefined; const history = sessionHistories.get(sessionId); if (history && history.length > 0) { return history[history.length - 1]; } logger.debug(`No history found for session ${sessionId} when getting last interaction.`); return undefined; } export function getSessionHistory(sessionId) { if (!sessionId || typeof sessionId !== 'string') return []; return sessionHistories.get(sessionId) || []; } export function clearSessionHistory(sessionId) { if (!sessionId || typeof sessionId !== 'string') return; if (sessionHistories.has(sessionId)) { sessionHistories.delete(sessionId); logger.info(`Cleared history for session ${sessionId}.`); } else { logger.debug(`Attempted to clear history for non-existent session ${sessionId}.`); } } export function clearAllHistories() { sessionHistories.clear(); logger.info('Cleared all session histories.'); }