Skip to content

iejoys/AMEP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

9 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

AMEP Protocol

npm version License: MIT

AHIVE Memory Encoding Protocol - Plug-and-play memory management for AI agents.

ไธญๆ–‡ๆ–‡ๆกฃ | Usage Guide


๐Ÿ“– Overview

AMEP is a plug-and-play memory management protocol library for AI agents, providing memory storage, semantic retrieval, and context management capabilities.

Core Features

Feature Description
๐Ÿง  Water Meter Mode Full message flow management: record โ†’ retrieve โ†’ respond
๐Ÿ” Semantic Retrieval BGE vector search with time range filtering
๐Ÿ’พ Memory Persistence Session recovery, automatic history loading
๐Ÿ—œ๏ธ Memory Extraction LLM-based key information extraction
๐ŸŒ Multi-Backend Local GGUF, Ollama, OpenAI-compatible APIs

Comparison with Other Solutions

Feature AMEP LangChain Memory Mem0
Zero-config startup โœ… โŒ โŒ
Local model support โœ… Built-in โŒ โŒ
Water Meter Mode โœ… Fully managed โŒ Manual โš ๏ธ Partial
Chinese optimized โœ… BGE-small-zh โš ๏ธ Needs config โš ๏ธ Needs config
Memory extraction โœ… LLM automatic โŒ โœ…
Package size ~1MB ~50MB ~10MB

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      Your Agent                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                          โ”‚
                          โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    AMEP Water Meter Mode                     โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”‚
โ”‚  โ”‚  Record  โ”‚โ†’โ”‚  Decide  โ”‚โ†’โ”‚  Retrieve โ”‚โ†’โ”‚ Call LLM โ”‚    โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                          โ”‚
          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
          โ–ผ               โ–ผ               โ–ผ
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚BGE Embed โ”‚    โ”‚Faiss Indexโ”‚    โ”‚ MD Store โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Message Flow

User Message
    โ”‚
    โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ 1. Record User  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚
         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ 2. Retrieval    โ”‚  โ† LLM decides if retrieval needed
โ”‚    Decision     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚ Need?
    โ”Œโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”
    โ”‚ Yes     โ”‚ No
    โ–ผ         โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ 3. Search โ”‚ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
      โ”‚       โ”‚
      โ–ผ       โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ 4. Contextโ”‚ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
      โ”‚       โ”‚
      โ””โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”˜
          โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ 5. Call LLM     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚
         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ 6. Record Reply โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚
         โ–ผ
    Return Response

๐Ÿ“Š Performance

Metric Value Description
Embedding speed ~10ms BGE-small-zh single query
Retrieval latency <50ms Faiss HNSW index
Memory compression 85-90% After LLM extraction
Memory usage ~100MB Including embedding model
Startup time <2s Cold start

๐Ÿ“ฆ Installation

# Basic installation (with mock embedding)
npm install amep-protocol

# Full installation (with BGE embedding model)
npm install amep-protocol @huggingface/transformers

๐Ÿš€ Quick Start

Basic Usage

import { createAMEP } from 'amep-protocol';

const amep = createAMEP({
  storage: { basePath: './data/amep' },
});
await amep.initialize();

// Store memory
await amep.createMemory({
  userId: 'user-001',
  content: 'User prefers dark mode',
});

// Search memory
const memories = await amep.search({
  query: 'user preferences',
  userId: 'user-001',
});

Water Meter Mode (Recommended)

import type { LLMService } from 'amep-protocol';

// 1. Implement LLMService interface
const llmService: LLMService = {
  chat: async (options) => {
    const response = await yourLLM.chat(options.messages);
    return { content: response.content };
  },
};

// 2. Use water meter mode
const result = await amep.processMessage({
  message: 'What did we discuss yesterday?',
  userId: 'user-001',
  systemPrompt: 'You are a helpful assistant.',
  llmService,
});

console.log(result.content);            // LLM response
console.log(result.retrievalTriggered); // Whether retrieval was triggered

๐Ÿ“– Full Usage Guide: USAGE.md


โš™๏ธ Configuration

const amep = createAMEP({
  storage: {
    basePath: './data/amep',    // Storage path
    retentionDays: 90,          // Memory retention days
  },
  embedding: {
    modelType: 'bge-small-zh',  // Embedding model
  },
  retrieval: {
    maxResults: 5,              // Max retrieval results
  },
  session: {
    maxContextMessages: 20,     // Context message count
  },
});

๐Ÿ”ง API Reference

Method Description
initialize() Initialize the service
createMemory(options) Store memory
search(options) Search memories
processMessage(options) Water meter mode - process message
getStartupContext(options) Get startup context (restore history)
endSession(sessionId) End session (trigger memory extraction)

โ“ FAQ

Q: Why is it called "Water Meter Mode"?

Water Meter Mode means all messages flow through AMEP, just like water flows through a meter to be measured and recorded. AMEP automatically handles recording, retrieval, and LLM calls.

Q: What embedding models are supported?

  • bge-small-zh: Chinese optimized, 512 dimensions, ~100MB (recommended)
  • bge-m3: Multilingual, 1024 dimensions
  • mock: For testing, zero dependencies

Q: How to integrate with local models?

const llmService: LLMService = {
  chat: async (options) => {
    const response = await localModel.chat(options.messages);
    return { content: response.content };
  },
};

Q: How is memory persisted?

By default, uses Markdown file storage with:

  • User/agent isolation
  • Automatic archiving
  • 90-day retention

Q: Does it support multi-user?

Yes. Use userId and agentId to distinguish different users and agents. Memories are completely isolated.


๐Ÿ“„ License

MIT License ยฉ 2026 StarFuture Software Studio (AHIVE.CN)



๐Ÿ“– ไธญๆ–‡ๆ–‡ๆกฃ

AMEP (AHIVE Memory Encoding Protocol) ๆ˜ฏไธ€ไธชๅณๆ’ๅณ็”จ็š„ๆ™บ่ƒฝไฝ“่ฎฐๅฟ†็ฎก็†ๅ่ฎฎๅบ“๏ผŒๆไพ›่ฎฐๅฟ†ๅญ˜ๅ‚จใ€่ฏญไน‰ๆฃ€็ดขใ€ไธŠไธ‹ๆ–‡็ฎก็†่ƒฝๅŠ›ใ€‚

ๆ ธๅฟƒ็‰นๆ€ง

็‰นๆ€ง ่ฏดๆ˜Ž
๐Ÿง  ๆฐด่กจๆจกๅผ ๆถˆๆฏๆตๅ…จๆ‰˜็ฎก๏ผŒ่‡ชๅŠจๅฎŒๆˆ่ฎฐๅฝ•โ†’ๆฃ€็ดขโ†’ๅ›žๅค
๐Ÿ” ่ฏญไน‰ๆฃ€็ดข BGE ๅ‘้‡ๆฃ€็ดข๏ผŒๆ”ฏๆŒๆ—ถ้—ด่Œƒๅ›ด่ฟ‡ๆปค
๐Ÿ’พ ่ฎฐๅฟ†ๆฐธ็ปญ ไผš่ฏๆขๅค๏ผŒๅކๅฒๅฏน่ฏ่‡ชๅŠจๅŠ ่ฝฝ
๐Ÿ—œ๏ธ ่ฎฐๅฟ†ๆ็บฏ LLM ๆๅ–ๅ…ณ้”ฎไฟกๆฏ๏ผŒๅŽ‹็ผฉๅญ˜ๅ‚จ
๐ŸŒ ๅคšๅŽ็ซฏๆ”ฏๆŒ ๆœฌๅœฐ GGUFใ€Ollamaใ€OpenAI ๅ…ผๅฎน API

ๅฎ‰่ฃ…

npm install amep-protocol

ๅฟซ้€Ÿๅผ€ๅง‹

import { createAMEP } from 'amep-protocol';

const amep = createAMEP();
await amep.initialize();

// ๆฐด่กจๆจกๅผ
const result = await amep.processMessage({
  message: 'ๆˆ‘ไปฌๆ˜จๅคฉ่Šไบ†ไป€ไนˆ๏ผŸ',
  userId: 'user-001',
  llmService: myLLMService,
});

ๅธธ่ง้—ฎ้ข˜

Q: ไธบไป€ไนˆๅซ"ๆฐด่กจๆจกๅผ"๏ผŸ

ๆฐด่กจๆจกๅผๆฏ”ๅ–ปๆ‰€ๆœ‰ๆถˆๆฏๆต้ƒฝ็ป่ฟ‡ AMEP๏ผŒๅฐฑๅƒ่‡ชๆฅๆฐด็ป่ฟ‡ๆฐด่กจไธ€ๆ ท่ขซ่ฎก้‡ๅ’Œ่ฎฐๅฝ•ใ€‚

Q: ๆ”ฏๆŒๅ“ชไบ›ๅตŒๅ…ฅๆจกๅž‹๏ผŸ

  • bge-small-zh: ไธญๆ–‡ไผ˜ๅŒ–๏ผˆๆŽจ่๏ผ‰
  • bge-m3: ๅคš่ฏญ่จ€
  • mock: ๆต‹่ฏ•็”จ

ๅฎšไฝ๏ผšๆ™บ่ƒฝไฝ“่ฎฐๅฟ†็ฎก็†็š„ "Windows DLL"

About

๐Ÿง  Agent Memory Protocol - Plug-and-play memory management for AI agents. Semantic retrieval, vector search, and persistent storage in one npm package.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors