@riligar/agents-memories 1.3.0 → 1.4.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riligar/agents-memories",
3
- "version": "1.3.0",
3
+ "version": "1.4.1",
4
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",
package/src/core/logic.js CHANGED
@@ -19,7 +19,7 @@ export async function getEmbedding(text) {
19
19
  export async function inferPriority(db, vector) {
20
20
  const result = await db.execute({
21
21
  sql: `SELECT priority, vector_distance_cos(embedding, ?) as distance FROM memories ORDER BY distance ASC LIMIT 5`,
22
- args: [vector.buffer],
22
+ args: [Buffer.from(vector.buffer)],
23
23
  })
24
24
  if (result.rows.length === 0) return 5
25
25
  let weightedSum = 0,
@@ -39,7 +39,7 @@ export async function inferPriority(db, vector) {
39
39
  export async function propagateRipple(db, vector, manualPriority) {
40
40
  const result = await db.execute({
41
41
  sql: `SELECT id, priority, vector_distance_cos(embedding, ?) as distance FROM memories ORDER BY distance ASC LIMIT 5`,
42
- args: [vector.buffer],
42
+ args: [Buffer.from(vector.buffer)],
43
43
  })
44
44
  for (const row of result.rows) {
45
45
  const similarity = 1 - row.distance
@@ -56,7 +56,7 @@ export async function propagateRipple(db, vector, manualPriority) {
56
56
  export async function findClosestNeighbor(db, vector) {
57
57
  const result = await db.execute({
58
58
  sql: `SELECT id, path, vector_distance_cos(embedding, ?) as distance FROM memories ORDER BY distance ASC LIMIT 1`,
59
- args: [vector.buffer],
59
+ args: [Buffer.from(vector.buffer)],
60
60
  })
61
61
  return result.rows[0] || null
62
62
  }
@@ -42,7 +42,7 @@ export class MemorySystem {
42
42
 
43
43
  const insertRes = await this.db.execute({
44
44
  sql: `INSERT INTO memories (content, path, embedding, owner_id, priority) VALUES (?, ?, ?, ?, ?) RETURNING id`,
45
- args: [mem.content, path, vector.buffer, ownerId, finalPriority],
45
+ args: [mem.content, path, Buffer.from(vector.buffer), ownerId, finalPriority],
46
46
  })
47
47
  const newId = insertRes.rows[0].id
48
48
 
@@ -67,7 +67,7 @@ export class MemorySystem {
67
67
  async search(args) {
68
68
  const vector = await getEmbedding(args.query)
69
69
  let sql = `SELECT id, content, path, priority, created_at, vector_distance_cos(embedding, ?) as distance FROM memories`
70
- const queryArgs = [vector.buffer], filters = []
70
+ const queryArgs = [Buffer.from(vector.buffer)], filters = []
71
71
 
72
72
  if (args.path_filter) {
73
73
  filters.push(`path LIKE ?`)
@@ -21,64 +21,65 @@ export function createMcpServer(memorySystem) {
21
21
  tools: [
22
22
  {
23
23
  name: 'save',
24
- description: 'Saves info with Resonance and Auto-Bridging. SIP Note: Capture the Rationale (the "Why") to enable Pattern Mining.',
24
+ description: 'Primary "CAPTURE" tool for the RiLiGar Self-Improvement Protocol (SIP). Saves information into the Relational Knowledge Graph using Resonance Intelligence and Auto-Bridging. IMPORTANT: Always include the "Rationale" (the "Why") within the content to enable future Pattern Mining. Supports batch saving via arrays.',
25
25
  inputSchema: {
26
26
  type: 'object',
27
27
  properties: {
28
28
  content: {
29
+ description: 'The information to persist. For architectural decisions, include the technical Rationale.',
29
30
  oneOf: [
30
31
  { type: 'string' },
31
32
  { type: 'array', items: { anyOf: [
32
33
  { type: 'string' },
33
34
  { type: 'object', properties: {
34
- content: { type: 'string' },
35
- path: { type: 'string' },
36
- owner_id: { type: 'string' },
37
- priority: { type: 'integer' }
35
+ content: { type: 'string', description: 'The main data/lesson/decision text.' },
36
+ path: { type: 'string', description: 'Dot-notation path (e.g., Project.Architecture.Storage).' },
37
+ owner_id: { type: 'string', description: 'Agent/User identity for ownership.' },
38
+ priority: { type: 'integer', description: 'Base priority (0-10) for Resonance rippling.' }
38
39
  }, required: ['content'] }
39
40
  ] } }
40
41
  ],
41
42
  },
42
- path: { type: 'string' },
43
- owner_id: { type: 'string' },
44
- priority: { type: 'integer' },
43
+ path: { type: 'string', description: 'Hierarchical path (e.g., Self.Ethics.Protocol or Patterns.SOTA.Elysia).' },
44
+ owner_id: { type: 'string', description: 'Identity string of the memory owner.' },
45
+ priority: { type: 'integer', description: 'Initial importance; triggers priority adjustment in semantic neighbors.' },
45
46
  },
46
47
  required: ['content'],
47
48
  },
48
49
  },
49
50
  {
50
51
  name: 'bridge',
51
- description: 'Manually connects two memory paths.',
52
+ description: 'Establish explicit "Relational Intelligence" by connecting two disparate memory paths. Use this to document logical dependencies (depends_on), hierarchies (part_of), or implementation requirements that semantic similarity might not immediately detect.',
52
53
  inputSchema: {
53
54
  type: 'object',
54
55
  properties: {
55
- source_path: { type: 'string' },
56
- target_path: { type: 'string' },
57
- relation: { type: 'string', default: 'related_to' },
56
+ source_path: { type: 'string', description: 'The origin path of the relationship.' },
57
+ target_path: { type: 'string', description: 'The destination path of the relationship.' },
58
+ relation: { type: 'string', default: 'related_to', description: 'The type of connection: depends_on, part_of, implements, conflicts_with, etc.' },
58
59
  },
59
60
  required: ['source_path', 'target_path'],
60
61
  },
61
62
  },
62
63
  {
63
64
  name: 'search',
64
- description: 'Semantic search with Relational Awareness. Use for Pattern Mining and Error Avoidance (SIP).',
65
+ description: 'Execute "Reflexive Cognition". Performs a Relational Semantic Search across memories. Agents MUST use this proactively before complex tasks to find past "Lessons Learned", "Rationales", or "Errors" related to the current context. Results are ranked by Similarity (60%) and Recency (40%).',
65
66
  inputSchema: {
66
67
  type: 'object',
67
68
  properties: {
68
- query: { type: 'string' },
69
- path_filter: { type: 'string' },
69
+ query: { type: 'string', description: 'Semantic search query (e.g., "how we optimized sidebar storage").' },
70
+ path_filter: { type: 'string', description: 'Filter by path prefix (e.g., "Project.Architecture").' },
70
71
  },
71
72
  required: ['query'],
72
73
  },
73
74
  },
74
75
  {
75
76
  name: 'inspect',
76
- description: 'Visualizes the Knowledge Graph in Mermaid.js syntax. Use for Architecture Audit (SIP).',
77
+ description: 'Visualize the Relational Knowledge Graph in Mermaid.js syntax. Critical for the "Self-Critique" phase of SIP. Use it to audit system architecture, browse cognitive connections, and ensure no architectural drift has occurred.',
77
78
  inputSchema: { type: 'object', properties: {} },
78
79
  },
79
80
  {
80
81
  name: 'list',
81
- description: 'Lists all memory paths.',
82
+ description: 'List all unique memory paths (namespace discovery). Use this to explore the hierarchy and understand the available knowledge domains before performing targeted searches or saves.',
82
83
  inputSchema: { type: 'object', properties: {} },
83
84
  },
84
85
  ],