agent-memory-engine 0.1.0__py3-none-any.whl
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.
- agent_memory/__init__.py +33 -0
- agent_memory/cli.py +142 -0
- agent_memory/client.py +355 -0
- agent_memory/config.py +28 -0
- agent_memory/controller/__init__.py +15 -0
- agent_memory/controller/conflict.py +95 -0
- agent_memory/controller/consolidation.py +136 -0
- agent_memory/controller/forgetting.py +29 -0
- agent_memory/controller/router.py +62 -0
- agent_memory/controller/trust.py +31 -0
- agent_memory/embedding/__init__.py +5 -0
- agent_memory/embedding/base.py +11 -0
- agent_memory/embedding/local_provider.py +38 -0
- agent_memory/embedding/openai_provider.py +11 -0
- agent_memory/extraction/__init__.py +5 -0
- agent_memory/extraction/entity_extractor.py +13 -0
- agent_memory/extraction/pipeline.py +123 -0
- agent_memory/extraction/prompts.py +40 -0
- agent_memory/governance/__init__.py +6 -0
- agent_memory/governance/audit.py +14 -0
- agent_memory/governance/export.py +72 -0
- agent_memory/governance/health.py +40 -0
- agent_memory/interfaces/__init__.py +14 -0
- agent_memory/interfaces/mcp_server.py +128 -0
- agent_memory/interfaces/rest_api.py +71 -0
- agent_memory/llm/__init__.py +5 -0
- agent_memory/llm/base.py +23 -0
- agent_memory/llm/ollama_client.py +64 -0
- agent_memory/llm/openai_client.py +94 -0
- agent_memory/models.py +149 -0
- agent_memory/storage/__init__.py +4 -0
- agent_memory/storage/base.py +59 -0
- agent_memory/storage/schema.sql +125 -0
- agent_memory/storage/sqlite_backend.py +762 -0
- agent_memory_engine-0.1.0.dist-info/METADATA +228 -0
- agent_memory_engine-0.1.0.dist-info/RECORD +39 -0
- agent_memory_engine-0.1.0.dist-info/WHEEL +4 -0
- agent_memory_engine-0.1.0.dist-info/entry_points.txt +2 -0
- agent_memory_engine-0.1.0.dist-info/licenses/LICENSE +22 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
PRAGMA foreign_keys = ON;
|
|
2
|
+
|
|
3
|
+
CREATE TABLE IF NOT EXISTS memories (
|
|
4
|
+
id TEXT PRIMARY KEY,
|
|
5
|
+
content TEXT NOT NULL,
|
|
6
|
+
memory_type TEXT NOT NULL,
|
|
7
|
+
created_at TEXT NOT NULL,
|
|
8
|
+
last_accessed TEXT NOT NULL,
|
|
9
|
+
access_count INTEGER NOT NULL DEFAULT 0,
|
|
10
|
+
valid_from TEXT,
|
|
11
|
+
valid_until TEXT,
|
|
12
|
+
trust_score REAL NOT NULL,
|
|
13
|
+
importance REAL NOT NULL,
|
|
14
|
+
layer TEXT NOT NULL,
|
|
15
|
+
decay_rate REAL NOT NULL,
|
|
16
|
+
source_id TEXT NOT NULL,
|
|
17
|
+
causal_parent_id TEXT REFERENCES memories(id),
|
|
18
|
+
supersedes_id TEXT REFERENCES memories(id),
|
|
19
|
+
entity_refs_json TEXT NOT NULL,
|
|
20
|
+
tags_json TEXT NOT NULL,
|
|
21
|
+
deleted_at TEXT
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
CREATE TABLE IF NOT EXISTS memory_vectors (
|
|
25
|
+
memory_id TEXT PRIMARY KEY REFERENCES memories(id) ON DELETE CASCADE,
|
|
26
|
+
memory_rowid INTEGER UNIQUE,
|
|
27
|
+
embedding_json TEXT NOT NULL
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
CREATE TABLE IF NOT EXISTS backend_meta (
|
|
31
|
+
key TEXT PRIMARY KEY,
|
|
32
|
+
value TEXT NOT NULL
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
CREATE TABLE IF NOT EXISTS entity_index (
|
|
36
|
+
entity TEXT NOT NULL,
|
|
37
|
+
memory_id TEXT NOT NULL REFERENCES memories(id) ON DELETE CASCADE,
|
|
38
|
+
PRIMARY KEY (entity, memory_id)
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
CREATE TABLE IF NOT EXISTS relations (
|
|
42
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
43
|
+
source_id TEXT NOT NULL REFERENCES memories(id) ON DELETE CASCADE,
|
|
44
|
+
target_id TEXT NOT NULL REFERENCES memories(id) ON DELETE CASCADE,
|
|
45
|
+
relation_type TEXT NOT NULL,
|
|
46
|
+
created_at TEXT NOT NULL,
|
|
47
|
+
UNIQUE (source_id, target_id, relation_type)
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
CREATE TABLE IF NOT EXISTS evolution_log (
|
|
51
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
52
|
+
memory_id TEXT NOT NULL REFERENCES memories(id) ON DELETE CASCADE,
|
|
53
|
+
event_type TEXT NOT NULL,
|
|
54
|
+
payload_json TEXT NOT NULL,
|
|
55
|
+
created_at TEXT NOT NULL
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
CREATE TABLE IF NOT EXISTS audit_log (
|
|
59
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
60
|
+
actor TEXT NOT NULL,
|
|
61
|
+
operation TEXT NOT NULL,
|
|
62
|
+
target_type TEXT NOT NULL,
|
|
63
|
+
target_id TEXT NOT NULL,
|
|
64
|
+
payload_json TEXT NOT NULL,
|
|
65
|
+
created_at TEXT NOT NULL
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
CREATE INDEX IF NOT EXISTS idx_memories_memory_type ON memories(memory_type);
|
|
69
|
+
CREATE INDEX IF NOT EXISTS idx_memories_layer ON memories(layer);
|
|
70
|
+
CREATE INDEX IF NOT EXISTS idx_memories_created_at ON memories(created_at DESC);
|
|
71
|
+
CREATE INDEX IF NOT EXISTS idx_memories_last_accessed ON memories(last_accessed DESC);
|
|
72
|
+
CREATE INDEX IF NOT EXISTS idx_memories_trust_score ON memories(trust_score DESC);
|
|
73
|
+
CREATE INDEX IF NOT EXISTS idx_memories_source_id ON memories(source_id);
|
|
74
|
+
CREATE INDEX IF NOT EXISTS idx_memories_causal_parent_id ON memories(causal_parent_id);
|
|
75
|
+
CREATE INDEX IF NOT EXISTS idx_memories_supersedes_id ON memories(supersedes_id);
|
|
76
|
+
CREATE INDEX IF NOT EXISTS idx_memories_deleted_at ON memories(deleted_at);
|
|
77
|
+
CREATE INDEX IF NOT EXISTS idx_memories_active_type_created ON memories(deleted_at, memory_type, created_at DESC);
|
|
78
|
+
CREATE INDEX IF NOT EXISTS idx_entity_index_memory_id ON entity_index(memory_id);
|
|
79
|
+
CREATE INDEX IF NOT EXISTS idx_relations_source_type ON relations(source_id, relation_type);
|
|
80
|
+
CREATE INDEX IF NOT EXISTS idx_relations_target_type ON relations(target_id, relation_type);
|
|
81
|
+
CREATE INDEX IF NOT EXISTS idx_evolution_memory_created ON evolution_log(memory_id, created_at DESC);
|
|
82
|
+
CREATE INDEX IF NOT EXISTS idx_audit_target_created ON audit_log(target_id, created_at DESC);
|
|
83
|
+
|
|
84
|
+
CREATE VIRTUAL TABLE IF NOT EXISTS memories_fts
|
|
85
|
+
USING fts5(
|
|
86
|
+
content,
|
|
87
|
+
tags,
|
|
88
|
+
content = 'memories',
|
|
89
|
+
content_rowid = 'rowid'
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
CREATE TRIGGER IF NOT EXISTS memories_ai AFTER INSERT ON memories BEGIN
|
|
93
|
+
INSERT INTO memories_fts(rowid, content, tags)
|
|
94
|
+
VALUES (
|
|
95
|
+
new.rowid,
|
|
96
|
+
new.content,
|
|
97
|
+
trim(replace(replace(replace(replace(new.tags_json, '[', ' '), ']', ' '), '\"', ' '), ',', ' '))
|
|
98
|
+
);
|
|
99
|
+
END;
|
|
100
|
+
|
|
101
|
+
CREATE TRIGGER IF NOT EXISTS memories_ad AFTER DELETE ON memories BEGIN
|
|
102
|
+
INSERT INTO memories_fts(memories_fts, rowid, content, tags)
|
|
103
|
+
VALUES (
|
|
104
|
+
'delete',
|
|
105
|
+
old.rowid,
|
|
106
|
+
old.content,
|
|
107
|
+
trim(replace(replace(replace(replace(old.tags_json, '[', ' '), ']', ' '), '\"', ' '), ',', ' '))
|
|
108
|
+
);
|
|
109
|
+
END;
|
|
110
|
+
|
|
111
|
+
CREATE TRIGGER IF NOT EXISTS memories_au AFTER UPDATE ON memories BEGIN
|
|
112
|
+
INSERT INTO memories_fts(memories_fts, rowid, content, tags)
|
|
113
|
+
VALUES (
|
|
114
|
+
'delete',
|
|
115
|
+
old.rowid,
|
|
116
|
+
old.content,
|
|
117
|
+
trim(replace(replace(replace(replace(old.tags_json, '[', ' '), ']', ' '), '\"', ' '), ',', ' '))
|
|
118
|
+
);
|
|
119
|
+
INSERT INTO memories_fts(rowid, content, tags)
|
|
120
|
+
VALUES (
|
|
121
|
+
new.rowid,
|
|
122
|
+
new.content,
|
|
123
|
+
trim(replace(replace(replace(replace(new.tags_json, '[', ' '), ']', ' '), '\"', ' '), ',', ' '))
|
|
124
|
+
);
|
|
125
|
+
END;
|