🚀 Now Available on npm

AI Agent Memory
Made Simple

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.

Get Started
100% Test Coverage
5.4kB Bundle Size
TypeScript First
Live Demo
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"
> User Alice is excited about planning vacation

Why MindCache?

Built specifically for AI agents and LLM integration

🧠

LLM-Optimized

Data formats designed for optimal AI agent comprehension and reasoning

Template Injection

Dynamic placeholder replacement perfect for generating context-aware AI prompts

🔄

Reactive Updates

Event-driven system with listeners for real-time memory state changes

🕒

Temporal Context

Built-in $date and $time values automatically available in all operations

🛠️

Tool Integration

Direct integration with LLM tool calling systems and Vercel AI SDK

📝

TypeScript First

Full type safety with excellent developer experience and IntelliSense

Quick Start

Get up and running in minutes

1

Install

npm install mindcache
2

Import

import { mindcache } from 'mindcache';
3

Use

mindcache.set('user', 'Alice');
mindcache.get('user'); // 'Alice'

Examples

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}'
);

Persistent Conversation Memory

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);

Context-Aware Prompts

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!');
  }
});

Agent Workflow Management

Manage complex multi-step workflows with state tracking and event-driven updates.

Documentation

Complete API reference and guides

Copied to clipboard!