@riligar/agents-memories 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -44
- package/package.json +2 -2
- package/src/core/sip.js +30 -0
- package/src/server/mcp-server.js +40 -6
package/README.md
CHANGED
|
@@ -1,78 +1,110 @@
|
|
|
1
1
|
# RiLiGar Agents Memories
|
|
2
2
|
|
|
3
|
-
A high-performance, persistent memory system for AI agents, built on the **Model Context Protocol (MCP)**.
|
|
3
|
+
A high-performance, persistent memory system for AI agents, built on the **Model Context Protocol (MCP)**. RiLiGar transforms flat data into a **Relational Knowledge Graph** featuring **Resonance Intelligence** and **Semantic Bridging**.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Now evolved into a **Modular SDK**, RiLiGar can be used both as a standalone MCP server and as a core library for cognitive applications.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## 🧠 Philosophy: The Cognitive Self
|
|
8
8
|
|
|
9
|
-
RiLiGar focuses on **Relational Intelligence**. By transforming memories into a living graph, the agent
|
|
9
|
+
RiLiGar focuses on **Relational Intelligence**. Memory is not just retrieval; it is an extension of the agent's identity. By transforming memories into a living graph, the agent understands how facts are interconnected across different domains, simulating a "working memory" that evolves with every interaction.
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
Each RiLiGar installation possesses a unique, professional cryptographic identity (Ed25519):
|
|
11
|
+
---
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
- **Explicit Identity**: Users or external agents can provide their own `owner_id` to maintain clear boundaries in multi-user environments.
|
|
17
|
-
- **Architecture**: Stored locally in `data/identity.json`, ensuring the agent maintains its "soul" across sessions.
|
|
13
|
+
## 🏗️ Modular Architecture
|
|
18
14
|
|
|
19
|
-
|
|
15
|
+
The project is organized into distinct layers to ensure scalability and maintainability:
|
|
20
16
|
|
|
21
|
-
|
|
17
|
+
- **`src/core` (Cognition)**: Implements the heavy-lifting logic:
|
|
18
|
+
- **Resonance Intelligence**: Priorities ripple through the graph; if a node is marked as critical, its semantic neighbors gain importance.
|
|
19
|
+
- **Semantic Magnet**: Automatically detects near-identical facts and creates `similar_to` links.
|
|
20
|
+
- **`src/database` (Persistence)**: Uses **LibSQL (SQLite)** for edge-ready, high-speed storage.
|
|
21
|
+
- **`src/sdk` (Interface)**: Provides the `MemorySystem` class, a clean programmatic API.
|
|
22
|
+
- **`src/server` (Transport)**: Handles MCP communication via **Stdio** (local) and **SSE** (web/remote).
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
- **Manual Bridging**: Explicitly connect disparate paths using the `bridge` tool to establish logical dependencies (e.g., `Architecture` depends_on `Infrastructure`).
|
|
25
|
-
- **Resonance Intelligence**: Priorities ripple through the graph; if a node is marked as critical, its semantic neighbors gain importance via resonance.
|
|
24
|
+
---
|
|
26
25
|
|
|
27
|
-
##
|
|
26
|
+
## 🔌 Quick Start
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
### Prerequisites
|
|
30
29
|
|
|
31
|
-
-
|
|
32
|
-
- **Output**: Generates a visual mental map of all connections, allowing the agent and user to see the topology of their stored knowledge.
|
|
30
|
+
- [Bun](https://bun.sh) runtime (v1.x+)
|
|
33
31
|
|
|
34
|
-
|
|
32
|
+
### Installation
|
|
35
33
|
|
|
36
|
-
|
|
34
|
+
```bash
|
|
35
|
+
bun install
|
|
36
|
+
```
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
`🔗 Related: Path.B (similar_to), Path.C (depends_on)`
|
|
38
|
+
### Running the Standalone Server
|
|
40
39
|
|
|
41
|
-
|
|
42
|
-
- **Short-term Awareness**: The system is tuned for **Cognitive Fluidity**, prioritizing recent thoughts and context to function as an effective short-term "working memory" while maintaining long-term relational links.
|
|
40
|
+
The server starts both **Stdio** and **SSE** transports simultaneously on port `3000`.
|
|
43
41
|
|
|
44
|
-
|
|
42
|
+
```bash
|
|
43
|
+
bun start
|
|
44
|
+
```
|
|
45
45
|
|
|
46
|
-
-
|
|
47
|
-
- `
|
|
48
|
-
- `bridge`: Manually links two memory paths with a specified relation type.
|
|
49
|
-
- `inspect`: Generates a Mermaid.js diagram of the current knowledge graph.
|
|
50
|
-
- `list`: Lists all unique memory paths.
|
|
46
|
+
- **Stdio**: Use this for Claude Desktop or local IDE configurations.
|
|
47
|
+
- **SSE**: Access via `http://localhost:3000/sse` for web dashboards or remote agents.
|
|
51
48
|
|
|
52
49
|
---
|
|
53
50
|
|
|
54
|
-
##
|
|
51
|
+
## 📦 Programmatic Usage (SDK)
|
|
55
52
|
|
|
56
|
-
|
|
53
|
+
You can use RiLiGar as a library in your own Bun projects:
|
|
57
54
|
|
|
58
|
-
|
|
55
|
+
```javascript
|
|
56
|
+
import { MemorySystem, getSystemIdentity } from '@riligar/agents-memories'
|
|
57
|
+
import { createClient } from '@libsql/client'
|
|
59
58
|
|
|
60
|
-
|
|
59
|
+
const db = createClient({ url: 'file:data/memories.db' })
|
|
60
|
+
const ownerId = getSystemIdentity('data')
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
```
|
|
62
|
+
const memory = new MemorySystem(db, ownerId)
|
|
63
|
+
await memory.init()
|
|
65
64
|
|
|
66
|
-
|
|
65
|
+
// Save a memory with automatic priority inference
|
|
66
|
+
await memory.save({
|
|
67
|
+
content: 'The architecture is now modular.',
|
|
68
|
+
path: 'Project.Architecture',
|
|
69
|
+
})
|
|
67
70
|
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
// Relational Semantic Search
|
|
72
|
+
const results = await memory.search({ query: 'How is the project organized?' })
|
|
73
|
+
console.log(results)
|
|
70
74
|
```
|
|
71
75
|
|
|
72
|
-
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## 🛡️ Identity & SaaS Readiness
|
|
79
|
+
|
|
80
|
+
- **Cryptographic Soul**: Each installation generates an Ed25519 identity (`data/identity.json`). The system uses a 10-character hex `owner_id` derived from this key.
|
|
81
|
+
- **Multi-Tenancy**: Every memory is bound to an `owner_id`, allowing the same database to securely host memories for multiple users or agents.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 🛠️ MCP Tools Reference
|
|
86
|
+
|
|
87
|
+
- `save`: Stores content with automatic priority inference and **Semantic Magnet** auto-linking.
|
|
88
|
+
- `search`: Relational semantic search (Score = 60% Similarity + 40% Recency).
|
|
89
|
+
- `bridge`: Manually links two memory paths (e.g., `Architecture` -> `Security`).
|
|
90
|
+
- `inspect`: Generates a **Mermaid.js** graph of the memory topology.
|
|
91
|
+
- `list`: Shows all unique memory paths.
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## 🧪 Development
|
|
96
|
+
|
|
97
|
+
### Running tests
|
|
73
98
|
|
|
74
99
|
```bash
|
|
75
|
-
bun
|
|
100
|
+
bun test
|
|
76
101
|
```
|
|
77
102
|
|
|
78
|
-
|
|
103
|
+
### Stack
|
|
104
|
+
|
|
105
|
+
- **Runtime**: [Bun](https://bun.sh)
|
|
106
|
+
- **Database**: [LibSQL](https://github.com/tursodatabase/libsql)
|
|
107
|
+
- **Embeddings**: [Transformers.js](https://huggingface.co/docs/transformers.js) (`all-MiniLM-L6-v2`)
|
|
108
|
+
- **Server**: [Express](https://expressjs.com/) + MCP SDK
|
|
109
|
+
|
|
110
|
+
**Built with ❤️ by the RiLiGar Team.**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riligar/agents-memories",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "RiLiGar Agents Memories - A
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "RiLiGar Agents Memories - A self-improving relational memory system for AI agents.",
|
|
5
5
|
"module": "src/index.js",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"type": "module",
|
package/src/core/sip.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-Improvement Protocol (SIP) - Protocol Definition
|
|
3
|
+
* This document defines the core pillars of the RiLiGar self-improvement loop.
|
|
4
|
+
*/
|
|
5
|
+
export const SIP_PROTOCOL = `
|
|
6
|
+
# RiLiGar Self-Improvement Protocol (SIP) v1.0
|
|
7
|
+
|
|
8
|
+
The SIP transforms the memory system from a passive database into an active, self-correcting cognitive engine. Every agent using this MCP should adhere to the following three pillars:
|
|
9
|
+
|
|
10
|
+
## 1. Pattern Mining (Refinamento de Padrões)
|
|
11
|
+
- **Goal**: Identify common failure points and recurring logic patterns.
|
|
12
|
+
- **Action**: When saving a new memory, always include the **Rationale** (the "Why").
|
|
13
|
+
- **Loop**: Before taking a complex action, use \`search\` to find "Lessons Learned" and "Past Failures" related to the current context.
|
|
14
|
+
|
|
15
|
+
## 2. Meta-Programming (Evolução de Skills)
|
|
16
|
+
- **Goal**: Update internal instructions and code patterns based on discovered "State of the Art" (SOTA) solutions.
|
|
17
|
+
- **Action**: If a specific implementation pattern proves superior (e.g., Elysia optimization), save it under \`Patterns.SOTA.*\` and update relevant local \`.agent/skills/\`.
|
|
18
|
+
|
|
19
|
+
## 3. Self-Critique (Auditoria de Arquitetura)
|
|
20
|
+
- **Goal**: Prevent technical debt and architectural drift.
|
|
21
|
+
- **Action**: Periodically use \`inspect\` and \`search\` with filter \`path:Project.Architecture.*\` to identify redundancies or legacy constraints.
|
|
22
|
+
- **Outcome**: Propose refactoring at the first sign of relational misalignment.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
### Execution Protocol
|
|
27
|
+
1. **CAPTURE**: Save rationale for every architectural decision.
|
|
28
|
+
2. **REFLECT**: Search for patterns before starting new tasks.
|
|
29
|
+
3. **EVOLVE**: Update skills and best practices paths based on successful outcomes.
|
|
30
|
+
`.trim();
|
package/src/server/mcp-server.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
CallToolRequestSchema,
|
|
4
|
+
ListToolsRequestSchema,
|
|
5
|
+
ListResourcesRequestSchema,
|
|
6
|
+
ReadResourceRequestSchema
|
|
7
|
+
} from '@modelcontextprotocol/sdk/types.js'
|
|
8
|
+
import { SIP_PROTOCOL } from '../core/sip.js'
|
|
3
9
|
|
|
4
10
|
/**
|
|
5
11
|
* Factory para criar o servidor MCP usando o SDK do RiLiGar.
|
|
6
12
|
*/
|
|
7
13
|
export function createMcpServer(memorySystem) {
|
|
8
14
|
const server = new Server(
|
|
9
|
-
{ name: 'RiLiGar Agents Memories', version: '4.
|
|
10
|
-
{ capabilities: { tools: {} } }
|
|
15
|
+
{ name: 'RiLiGar Agents Memories', version: '4.2.0' },
|
|
16
|
+
{ capabilities: { tools: {}, resources: {} } }
|
|
11
17
|
)
|
|
12
18
|
|
|
13
19
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
@@ -15,7 +21,7 @@ export function createMcpServer(memorySystem) {
|
|
|
15
21
|
tools: [
|
|
16
22
|
{
|
|
17
23
|
name: 'save',
|
|
18
|
-
description: 'Saves info with Resonance and Auto-Bridging (
|
|
24
|
+
description: 'Saves info with Resonance and Auto-Bridging. SIP Note: Capture the Rationale (the "Why") to enable Pattern Mining.',
|
|
19
25
|
inputSchema: {
|
|
20
26
|
type: 'object',
|
|
21
27
|
properties: {
|
|
@@ -55,7 +61,7 @@ export function createMcpServer(memorySystem) {
|
|
|
55
61
|
},
|
|
56
62
|
{
|
|
57
63
|
name: 'search',
|
|
58
|
-
description: 'Semantic search with Relational Awareness.',
|
|
64
|
+
description: 'Semantic search with Relational Awareness. Use for Pattern Mining and Error Avoidance (SIP).',
|
|
59
65
|
inputSchema: {
|
|
60
66
|
type: 'object',
|
|
61
67
|
properties: {
|
|
@@ -67,7 +73,7 @@ export function createMcpServer(memorySystem) {
|
|
|
67
73
|
},
|
|
68
74
|
{
|
|
69
75
|
name: 'inspect',
|
|
70
|
-
description: 'Visualizes the Knowledge Graph in Mermaid.js syntax.',
|
|
76
|
+
description: 'Visualizes the Knowledge Graph in Mermaid.js syntax. Use for Architecture Audit (SIP).',
|
|
71
77
|
inputSchema: { type: 'object', properties: {} },
|
|
72
78
|
},
|
|
73
79
|
{
|
|
@@ -79,6 +85,34 @@ export function createMcpServer(memorySystem) {
|
|
|
79
85
|
}
|
|
80
86
|
})
|
|
81
87
|
|
|
88
|
+
server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
|
89
|
+
return {
|
|
90
|
+
resources: [
|
|
91
|
+
{
|
|
92
|
+
uri: 'sip://protocol',
|
|
93
|
+
name: 'Self-Improvement Protocol (SIP)',
|
|
94
|
+
description: 'Protocolo de autoaperfeiçoamento contínuo para agentes RiLiGar.',
|
|
95
|
+
mimeType: 'text/markdown',
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
server.setRequestHandler(ReadResourceRequestSchema, async request => {
|
|
102
|
+
if (request.params.uri === 'sip://protocol') {
|
|
103
|
+
return {
|
|
104
|
+
contents: [
|
|
105
|
+
{
|
|
106
|
+
uri: 'sip://protocol',
|
|
107
|
+
mimeType: 'text/markdown',
|
|
108
|
+
text: SIP_PROTOCOL,
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
throw new Error('Resource not found')
|
|
114
|
+
})
|
|
115
|
+
|
|
82
116
|
server.setRequestHandler(CallToolRequestSchema, async request => {
|
|
83
117
|
const { name, arguments: args } = request.params
|
|
84
118
|
|