MindCache is a TypeScript library for managing short-term memory in AI agents through a simple, LLM-friendly key-value repository. Perfect for chatbots, AI assistants, and intelligent workflows.
import { mindcache } from 'mindcache';
// Set user context
mindcache.set('user', 'Alice');
mindcache.set('mood', 'excited');
mindcache.set('task', 'planning vacation');
// Template injection for AI prompts
const prompt = mindcache.injectSTM(
'User {user} is {mood} about {task}'
);
console.log(prompt);
// "User Alice is excited about planning vacation"
Built specifically for AI agents and LLM integration
Data formats designed for optimal AI agent comprehension and reasoning
Dynamic placeholder replacement perfect for generating context-aware AI prompts
Event-driven system with listeners for real-time memory state changes
Built-in $date and $time values automatically available in all operations
Direct integration with LLM tool calling systems and Vercel AI SDK
Full type safety with excellent developer experience and IntelliSense
Get up and running in minutes
npm install mindcache
import { mindcache } from 'mindcache';
mindcache.set('user', 'Alice');
mindcache.get('user'); // 'Alice'
Real-world use cases for AI agents
// Chatbot with conversation memory
import { mindcache } from 'mindcache';
// Store conversation context
mindcache.update({
userName: 'Alice',
lastTopic: 'travel planning',
userPreferences: { destination: 'Japan', budget: 5000 },
conversationStage: 'gathering requirements'
});
// Generate contextual response
const context = mindcache.getSTM();
const systemPrompt = `You are a travel assistant. Context: ${context}`;
// Use template injection
const greeting = mindcache.injectSTM(
'Hello {userName}! Let\'s continue planning your trip to {userPreferences.destination}'
);
Keep track of user context, preferences, and conversation state across multiple interactions.
// Dynamic AI prompt generation
import { mindcache } from 'mindcache';
// Set current context
mindcache.set('userMood', 'frustrated');
mindcache.set('issueType', 'billing');
mindcache.set('priority', 'high');
// Generate dynamic system prompt
const systemPrompt = mindcache.injectSTM(`
You are a customer service AI. The user is {userMood} about a {issueType} issue.
Priority level: {priority}. Today is {$date} at {$time}.
Respond with empathy and urgency appropriate to the situation.
`);
console.log(systemPrompt);
Generate dynamic AI prompts that adapt to current context and temporal information.
// Multi-step AI agent workflow
import { mindcache } from 'mindcache';
// Track workflow state
mindcache.update({
workflowId: 'order-processing',
currentStep: 'payment-verification',
stepProgress: 3,
totalSteps: 5,
userEmail: 'alice@example.com',
orderAmount: 299.99
});
// Listen for state changes
mindcache.subscribeToAll(() => {
const progress = mindcache.get('stepProgress');
const total = mindcache.get('totalSteps');
console.log(`Workflow progress: ${progress}/${total}`);
if (progress === total) {
console.log('Workflow completed!');
}
});
Manage complex multi-step workflows with state tracking and event-driven updates.