instar 0.9.37 → 0.9.39
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/dist/cli.js +68 -6
- package/dist/cli.js.map +1 -1
- package/dist/commands/semantic.d.ts +37 -0
- package/dist/commands/semantic.d.ts.map +1 -0
- package/dist/commands/semantic.js +198 -0
- package/dist/commands/semantic.js.map +1 -0
- package/dist/commands/setup.d.ts +6 -7
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +39 -1263
- package/dist/commands/setup.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/memory/SemanticMemory.d.ts +118 -0
- package/dist/memory/SemanticMemory.d.ts.map +1 -0
- package/dist/memory/SemanticMemory.js +635 -0
- package/dist/memory/SemanticMemory.js.map +1 -0
- package/dist/server/AgentServer.d.ts +1 -0
- package/dist/server/AgentServer.d.ts.map +1 -1
- package/dist/server/AgentServer.js +1 -0
- package/dist/server/AgentServer.js.map +1 -1
- package/dist/server/routes.d.ts +2 -0
- package/dist/server/routes.d.ts.map +1 -1
- package/dist/server/routes.js +229 -0
- package/dist/server/routes.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,635 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SemanticMemory — Entity-relationship knowledge store with FTS5 search.
|
|
3
|
+
*
|
|
4
|
+
* A typed, confidence-tracked knowledge graph stored in SQLite. Entities
|
|
5
|
+
* represent knowledge (facts, people, projects, tools, patterns, decisions,
|
|
6
|
+
* lessons) and edges represent relationships between them.
|
|
7
|
+
*
|
|
8
|
+
* Key features:
|
|
9
|
+
* - FTS5 full-text search with multi-signal ranking
|
|
10
|
+
* - Exponential confidence decay (lessons decay slower than facts)
|
|
11
|
+
* - BFS graph traversal with cycle detection
|
|
12
|
+
* - Export/import for portability
|
|
13
|
+
* - Formatted context generation for session injection
|
|
14
|
+
*
|
|
15
|
+
* Uses the same better-sqlite3 pattern as MemoryIndex and TopicMemory.
|
|
16
|
+
*/
|
|
17
|
+
import fs from 'node:fs';
|
|
18
|
+
import path from 'node:path';
|
|
19
|
+
import crypto from 'node:crypto';
|
|
20
|
+
/**
|
|
21
|
+
* Strip FTS5 special syntax characters from a query.
|
|
22
|
+
* Prevents query manipulation via AND, OR, NOT, NEAR, *, column filters.
|
|
23
|
+
*/
|
|
24
|
+
function sanitizeFts5Query(query) {
|
|
25
|
+
return query
|
|
26
|
+
.replace(/\b(AND|OR|NOT|NEAR)\b/gi, '')
|
|
27
|
+
.replace(/[*:"^{}().$@#!~`\\[\]]/g, '')
|
|
28
|
+
.replace(/\s+/g, ' ')
|
|
29
|
+
.trim();
|
|
30
|
+
}
|
|
31
|
+
export class SemanticMemory {
|
|
32
|
+
db = null;
|
|
33
|
+
config;
|
|
34
|
+
constructor(config) {
|
|
35
|
+
this.config = config;
|
|
36
|
+
}
|
|
37
|
+
// ─── Lifecycle ──────────────────────────────────────────────────
|
|
38
|
+
async open() {
|
|
39
|
+
if (this.db)
|
|
40
|
+
return;
|
|
41
|
+
let BetterSqlite3;
|
|
42
|
+
try {
|
|
43
|
+
BetterSqlite3 = await import('better-sqlite3');
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
throw new Error('SemanticMemory requires better-sqlite3. Run: npm install better-sqlite3');
|
|
47
|
+
}
|
|
48
|
+
const constructor = BetterSqlite3.default || BetterSqlite3;
|
|
49
|
+
// Ensure parent directory exists
|
|
50
|
+
const dbDir = path.dirname(this.config.dbPath);
|
|
51
|
+
if (!fs.existsSync(dbDir)) {
|
|
52
|
+
fs.mkdirSync(dbDir, { recursive: true });
|
|
53
|
+
}
|
|
54
|
+
this.db = constructor(this.config.dbPath);
|
|
55
|
+
this.db.pragma('journal_mode = WAL');
|
|
56
|
+
this.db.pragma('foreign_keys = ON');
|
|
57
|
+
this.createSchema();
|
|
58
|
+
}
|
|
59
|
+
close() {
|
|
60
|
+
if (this.db) {
|
|
61
|
+
this.db.close();
|
|
62
|
+
this.db = null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
ensureOpen() {
|
|
66
|
+
if (!this.db)
|
|
67
|
+
throw new Error('Database not open. Call open() first.');
|
|
68
|
+
return this.db;
|
|
69
|
+
}
|
|
70
|
+
// ─── Schema ─────────────────────────────────────────────────────
|
|
71
|
+
createSchema() {
|
|
72
|
+
const db = this.ensureOpen();
|
|
73
|
+
db.exec(`
|
|
74
|
+
CREATE TABLE IF NOT EXISTS entities (
|
|
75
|
+
id TEXT PRIMARY KEY,
|
|
76
|
+
type TEXT NOT NULL,
|
|
77
|
+
name TEXT NOT NULL,
|
|
78
|
+
content TEXT NOT NULL,
|
|
79
|
+
confidence REAL NOT NULL DEFAULT 1.0,
|
|
80
|
+
created_at TEXT NOT NULL,
|
|
81
|
+
last_verified TEXT NOT NULL,
|
|
82
|
+
last_accessed TEXT NOT NULL,
|
|
83
|
+
expires_at TEXT,
|
|
84
|
+
source TEXT NOT NULL,
|
|
85
|
+
source_session TEXT,
|
|
86
|
+
tags TEXT NOT NULL DEFAULT '[]',
|
|
87
|
+
domain TEXT
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
CREATE TABLE IF NOT EXISTS edges (
|
|
91
|
+
id TEXT PRIMARY KEY,
|
|
92
|
+
from_id TEXT NOT NULL,
|
|
93
|
+
to_id TEXT NOT NULL,
|
|
94
|
+
relation TEXT NOT NULL,
|
|
95
|
+
weight REAL NOT NULL DEFAULT 1.0,
|
|
96
|
+
context TEXT,
|
|
97
|
+
created_at TEXT NOT NULL,
|
|
98
|
+
UNIQUE(from_id, to_id, relation)
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
CREATE INDEX IF NOT EXISTS idx_edges_from ON edges(from_id);
|
|
102
|
+
CREATE INDEX IF NOT EXISTS idx_edges_to ON edges(to_id);
|
|
103
|
+
CREATE INDEX IF NOT EXISTS idx_entities_type ON entities(type);
|
|
104
|
+
CREATE INDEX IF NOT EXISTS idx_entities_confidence ON entities(confidence);
|
|
105
|
+
CREATE INDEX IF NOT EXISTS idx_entities_domain ON entities(domain);
|
|
106
|
+
|
|
107
|
+
CREATE VIRTUAL TABLE IF NOT EXISTS entities_fts USING fts5(
|
|
108
|
+
name,
|
|
109
|
+
content,
|
|
110
|
+
tags,
|
|
111
|
+
content='entities',
|
|
112
|
+
content_rowid='rowid',
|
|
113
|
+
tokenize='porter unicode61'
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
-- Triggers to keep FTS in sync with entities table
|
|
117
|
+
CREATE TRIGGER IF NOT EXISTS entities_fts_ai AFTER INSERT ON entities BEGIN
|
|
118
|
+
INSERT INTO entities_fts(rowid, name, content, tags)
|
|
119
|
+
VALUES (new.rowid, new.name, new.content, new.tags);
|
|
120
|
+
END;
|
|
121
|
+
|
|
122
|
+
CREATE TRIGGER IF NOT EXISTS entities_fts_ad AFTER DELETE ON entities BEGIN
|
|
123
|
+
INSERT INTO entities_fts(entities_fts, rowid, name, content, tags)
|
|
124
|
+
VALUES ('delete', old.rowid, old.name, old.content, old.tags);
|
|
125
|
+
END;
|
|
126
|
+
|
|
127
|
+
CREATE TRIGGER IF NOT EXISTS entities_fts_au AFTER UPDATE ON entities BEGIN
|
|
128
|
+
INSERT INTO entities_fts(entities_fts, rowid, name, content, tags)
|
|
129
|
+
VALUES ('delete', old.rowid, old.name, old.content, old.tags);
|
|
130
|
+
INSERT INTO entities_fts(rowid, name, content, tags)
|
|
131
|
+
VALUES (new.rowid, new.name, new.content, new.tags);
|
|
132
|
+
END;
|
|
133
|
+
`);
|
|
134
|
+
}
|
|
135
|
+
// ─── Entity CRUD ────────────────────────────────────────────────
|
|
136
|
+
/**
|
|
137
|
+
* Store a knowledge entity. Returns the generated UUID.
|
|
138
|
+
*/
|
|
139
|
+
remember(input) {
|
|
140
|
+
const db = this.ensureOpen();
|
|
141
|
+
const id = crypto.randomUUID();
|
|
142
|
+
const now = new Date().toISOString();
|
|
143
|
+
db.prepare(`
|
|
144
|
+
INSERT INTO entities (id, type, name, content, confidence, created_at, last_verified, last_accessed, expires_at, source, source_session, tags, domain)
|
|
145
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
146
|
+
`).run(id, input.type, input.name, input.content, input.confidence, now, input.lastVerified, now, input.expiresAt ?? null, input.source, input.sourceSession ?? null, JSON.stringify(input.tags), input.domain ?? null);
|
|
147
|
+
return id;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Retrieve an entity by ID, including its connections.
|
|
151
|
+
* Updates lastAccessed on read.
|
|
152
|
+
*/
|
|
153
|
+
recall(id) {
|
|
154
|
+
const db = this.ensureOpen();
|
|
155
|
+
const row = db.prepare('SELECT * FROM entities WHERE id = ?').get(id);
|
|
156
|
+
if (!row)
|
|
157
|
+
return null;
|
|
158
|
+
// Update lastAccessed
|
|
159
|
+
const now = new Date().toISOString();
|
|
160
|
+
db.prepare('UPDATE entities SET last_accessed = ? WHERE id = ?').run(now, id);
|
|
161
|
+
const entity = rowToEntity({ ...row, last_accessed: now });
|
|
162
|
+
// Get connections (both outgoing and incoming)
|
|
163
|
+
const connections = this.getConnections(db, id);
|
|
164
|
+
return { entity, connections };
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Delete an entity and all its edges.
|
|
168
|
+
*/
|
|
169
|
+
forget(id, _reason) {
|
|
170
|
+
const db = this.ensureOpen();
|
|
171
|
+
// Delete edges first (both directions)
|
|
172
|
+
db.prepare('DELETE FROM edges WHERE from_id = ? OR to_id = ?').run(id, id);
|
|
173
|
+
// Delete entity
|
|
174
|
+
db.prepare('DELETE FROM entities WHERE id = ?').run(id);
|
|
175
|
+
}
|
|
176
|
+
// ─── Edge CRUD ──────────────────────────────────────────────────
|
|
177
|
+
/**
|
|
178
|
+
* Create a relationship between two entities.
|
|
179
|
+
* Returns the edge ID. Silently returns existing edge ID if duplicate.
|
|
180
|
+
*/
|
|
181
|
+
connect(fromId, toId, relation, context, weight = 1.0) {
|
|
182
|
+
const db = this.ensureOpen();
|
|
183
|
+
// Check for existing edge with same (from, to, relation)
|
|
184
|
+
const existing = db.prepare('SELECT id FROM edges WHERE from_id = ? AND to_id = ? AND relation = ?').get(fromId, toId, relation);
|
|
185
|
+
if (existing)
|
|
186
|
+
return existing.id;
|
|
187
|
+
const id = crypto.randomUUID();
|
|
188
|
+
const now = new Date().toISOString();
|
|
189
|
+
db.prepare(`
|
|
190
|
+
INSERT INTO edges (id, from_id, to_id, relation, weight, context, created_at)
|
|
191
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
192
|
+
`).run(id, fromId, toId, relation, weight, context ?? null, now);
|
|
193
|
+
return id;
|
|
194
|
+
}
|
|
195
|
+
// ─── Search ─────────────────────────────────────────────────────
|
|
196
|
+
/**
|
|
197
|
+
* Full-text search with multi-signal ranking.
|
|
198
|
+
* Score = (fts5_rank * 0.4) + (confidence * 0.3) + (recency * 0.2) + (access_freq * 0.1)
|
|
199
|
+
*/
|
|
200
|
+
search(query, options) {
|
|
201
|
+
const db = this.ensureOpen();
|
|
202
|
+
const sanitized = sanitizeFts5Query(query);
|
|
203
|
+
if (!sanitized)
|
|
204
|
+
return [];
|
|
205
|
+
const limit = options?.limit ?? 20;
|
|
206
|
+
// Build the query
|
|
207
|
+
let sql = `
|
|
208
|
+
SELECT e.*, entities_fts.rank as fts_rank
|
|
209
|
+
FROM entities_fts
|
|
210
|
+
JOIN entities e ON e.rowid = entities_fts.rowid
|
|
211
|
+
WHERE entities_fts MATCH ?
|
|
212
|
+
`;
|
|
213
|
+
const params = [sanitized];
|
|
214
|
+
if (options?.types && options.types.length > 0) {
|
|
215
|
+
const placeholders = options.types.map(() => '?').join(',');
|
|
216
|
+
sql += ` AND e.type IN (${placeholders})`;
|
|
217
|
+
params.push(...options.types);
|
|
218
|
+
}
|
|
219
|
+
if (options?.domain) {
|
|
220
|
+
sql += ` AND e.domain = ?`;
|
|
221
|
+
params.push(options.domain);
|
|
222
|
+
}
|
|
223
|
+
if (options?.minConfidence !== undefined) {
|
|
224
|
+
sql += ` AND e.confidence >= ?`;
|
|
225
|
+
params.push(options.minConfidence);
|
|
226
|
+
}
|
|
227
|
+
sql += ` ORDER BY entities_fts.rank LIMIT ?`;
|
|
228
|
+
params.push(limit * 3); // Fetch extra for re-ranking
|
|
229
|
+
const rows = db.prepare(sql).all(...params);
|
|
230
|
+
// Multi-signal re-ranking
|
|
231
|
+
const now = Date.now();
|
|
232
|
+
const scored = rows.map(row => {
|
|
233
|
+
const entity = rowToEntity(row);
|
|
234
|
+
// Normalize FTS rank (BM25 returns negative, more negative = more relevant)
|
|
235
|
+
const ftsScore = 1 / (1 + Math.abs(row.fts_rank));
|
|
236
|
+
// Recency: how recently was this verified?
|
|
237
|
+
const daysSinceVerified = (now - new Date(entity.lastVerified).getTime()) / (1000 * 60 * 60 * 24);
|
|
238
|
+
const recencyScore = Math.exp(-0.02 * daysSinceVerified); // Gentle decay
|
|
239
|
+
// Access frequency proxy: recent access = higher value
|
|
240
|
+
const daysSinceAccessed = (now - new Date(entity.lastAccessed).getTime()) / (1000 * 60 * 60 * 24);
|
|
241
|
+
const accessScore = Math.exp(-0.01 * daysSinceAccessed);
|
|
242
|
+
const score = ftsScore * 0.4 +
|
|
243
|
+
entity.confidence * 0.3 +
|
|
244
|
+
recencyScore * 0.2 +
|
|
245
|
+
accessScore * 0.1;
|
|
246
|
+
return { ...entity, score };
|
|
247
|
+
});
|
|
248
|
+
// Sort by composite score (descending) and trim to limit
|
|
249
|
+
scored.sort((a, b) => b.score - a.score);
|
|
250
|
+
return scored.slice(0, limit);
|
|
251
|
+
}
|
|
252
|
+
// ─── Confidence Decay ───────────────────────────────────────────
|
|
253
|
+
/**
|
|
254
|
+
* Apply exponential confidence decay to all entities.
|
|
255
|
+
* formula: new_confidence = confidence * exp(-0.693 * days_since_verified / half_life)
|
|
256
|
+
*/
|
|
257
|
+
decayAll() {
|
|
258
|
+
const db = this.ensureOpen();
|
|
259
|
+
const rows = db.prepare('SELECT * FROM entities').all();
|
|
260
|
+
const now = Date.now();
|
|
261
|
+
let decayed = 0;
|
|
262
|
+
let expired = 0;
|
|
263
|
+
let minConf = Infinity;
|
|
264
|
+
let maxConf = -Infinity;
|
|
265
|
+
let sumConf = 0;
|
|
266
|
+
const update = db.prepare('UPDATE entities SET confidence = ? WHERE id = ?');
|
|
267
|
+
const del = db.prepare('DELETE FROM entities WHERE id = ?');
|
|
268
|
+
const delEdges = db.prepare('DELETE FROM edges WHERE from_id = ? OR to_id = ?');
|
|
269
|
+
const runDecay = db.transaction(() => {
|
|
270
|
+
for (const row of rows) {
|
|
271
|
+
const halfLife = row.type === 'lesson'
|
|
272
|
+
? this.config.lessonDecayHalfLifeDays
|
|
273
|
+
: this.config.decayHalfLifeDays;
|
|
274
|
+
const daysSinceVerified = (now - new Date(row.last_verified).getTime()) / (1000 * 60 * 60 * 24);
|
|
275
|
+
const newConfidence = row.confidence * Math.exp(-0.693 * daysSinceVerified / halfLife);
|
|
276
|
+
// Check hard expiry
|
|
277
|
+
if (row.expires_at && new Date(row.expires_at).getTime() < now) {
|
|
278
|
+
delEdges.run(row.id, row.id);
|
|
279
|
+
del.run(row.id);
|
|
280
|
+
expired++;
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
if (Math.abs(newConfidence - row.confidence) > 0.001) {
|
|
284
|
+
update.run(newConfidence, row.id);
|
|
285
|
+
decayed++;
|
|
286
|
+
minConf = Math.min(minConf, newConfidence);
|
|
287
|
+
maxConf = Math.max(maxConf, newConfidence);
|
|
288
|
+
sumConf += newConfidence;
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
minConf = Math.min(minConf, row.confidence);
|
|
292
|
+
maxConf = Math.max(maxConf, row.confidence);
|
|
293
|
+
sumConf += row.confidence;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
runDecay();
|
|
298
|
+
const activeCount = rows.length - expired;
|
|
299
|
+
return {
|
|
300
|
+
entitiesProcessed: rows.length,
|
|
301
|
+
entitiesDecayed: decayed,
|
|
302
|
+
entitiesExpired: expired,
|
|
303
|
+
minConfidence: activeCount > 0 ? minConf : 0,
|
|
304
|
+
maxConfidence: activeCount > 0 ? maxConf : 0,
|
|
305
|
+
avgConfidence: activeCount > 0 ? sumConf / activeCount : 0,
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
// ─── Verify ─────────────────────────────────────────────────────
|
|
309
|
+
/**
|
|
310
|
+
* Re-verify an entity, refreshing lastVerified and optionally updating confidence.
|
|
311
|
+
*/
|
|
312
|
+
verify(id, newConfidence) {
|
|
313
|
+
const db = this.ensureOpen();
|
|
314
|
+
const now = new Date().toISOString();
|
|
315
|
+
if (newConfidence !== undefined) {
|
|
316
|
+
db.prepare('UPDATE entities SET last_verified = ?, confidence = ? WHERE id = ?')
|
|
317
|
+
.run(now, newConfidence, id);
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
db.prepare('UPDATE entities SET last_verified = ? WHERE id = ?')
|
|
321
|
+
.run(now, id);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
// ─── Supersede ──────────────────────────────────────────────────
|
|
325
|
+
/**
|
|
326
|
+
* Mark an entity as superseded by a newer one.
|
|
327
|
+
* Creates a 'supersedes' edge and lowers the old entity's confidence.
|
|
328
|
+
*/
|
|
329
|
+
supersede(oldId, newId, reason) {
|
|
330
|
+
const db = this.ensureOpen();
|
|
331
|
+
// Create supersedes edge (new -> old)
|
|
332
|
+
this.connect(newId, oldId, 'supersedes', reason);
|
|
333
|
+
// Lower old entity's confidence by half
|
|
334
|
+
const old = db.prepare('SELECT confidence FROM entities WHERE id = ?').get(oldId);
|
|
335
|
+
if (old) {
|
|
336
|
+
db.prepare('UPDATE entities SET confidence = ? WHERE id = ?')
|
|
337
|
+
.run(old.confidence * 0.5, oldId);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
// ─── Graph Traversal ───────────────────────────────────────────
|
|
341
|
+
/**
|
|
342
|
+
* BFS graph traversal from a starting entity.
|
|
343
|
+
* Returns all reachable entities (excluding the start) up to maxDepth.
|
|
344
|
+
*/
|
|
345
|
+
explore(startId, options) {
|
|
346
|
+
const db = this.ensureOpen();
|
|
347
|
+
const maxDepth = options?.maxDepth ?? 2;
|
|
348
|
+
const relations = options?.relations;
|
|
349
|
+
const minWeight = options?.minWeight ?? 0;
|
|
350
|
+
const visited = new Set([startId]);
|
|
351
|
+
const result = [];
|
|
352
|
+
let frontier = [startId];
|
|
353
|
+
for (let depth = 0; depth < maxDepth && frontier.length > 0; depth++) {
|
|
354
|
+
const nextFrontier = [];
|
|
355
|
+
for (const nodeId of frontier) {
|
|
356
|
+
// Get outgoing edges
|
|
357
|
+
let outgoing = db.prepare('SELECT * FROM edges WHERE from_id = ?').all(nodeId);
|
|
358
|
+
// Get incoming edges
|
|
359
|
+
let incoming = db.prepare('SELECT * FROM edges WHERE to_id = ?').all(nodeId);
|
|
360
|
+
// Filter by relation type
|
|
361
|
+
if (relations) {
|
|
362
|
+
outgoing = outgoing.filter(e => relations.includes(e.relation));
|
|
363
|
+
incoming = incoming.filter(e => relations.includes(e.relation));
|
|
364
|
+
}
|
|
365
|
+
// Filter by weight
|
|
366
|
+
if (minWeight > 0) {
|
|
367
|
+
outgoing = outgoing.filter(e => e.weight >= minWeight);
|
|
368
|
+
incoming = incoming.filter(e => e.weight >= minWeight);
|
|
369
|
+
}
|
|
370
|
+
// Process outgoing: neighbor is the "to" end
|
|
371
|
+
for (const edge of outgoing) {
|
|
372
|
+
if (!visited.has(edge.to_id)) {
|
|
373
|
+
visited.add(edge.to_id);
|
|
374
|
+
const row = db.prepare('SELECT * FROM entities WHERE id = ?').get(edge.to_id);
|
|
375
|
+
if (row) {
|
|
376
|
+
result.push(rowToEntity(row));
|
|
377
|
+
nextFrontier.push(edge.to_id);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
// Process incoming: neighbor is the "from" end
|
|
382
|
+
for (const edge of incoming) {
|
|
383
|
+
if (!visited.has(edge.from_id)) {
|
|
384
|
+
visited.add(edge.from_id);
|
|
385
|
+
const row = db.prepare('SELECT * FROM entities WHERE id = ?').get(edge.from_id);
|
|
386
|
+
if (row) {
|
|
387
|
+
result.push(rowToEntity(row));
|
|
388
|
+
nextFrontier.push(edge.from_id);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
frontier = nextFrontier;
|
|
394
|
+
}
|
|
395
|
+
return result;
|
|
396
|
+
}
|
|
397
|
+
// ─── Stale Detection ───────────────────────────────────────────
|
|
398
|
+
/**
|
|
399
|
+
* Find entities that are stale (low confidence or old).
|
|
400
|
+
*/
|
|
401
|
+
findStale(options) {
|
|
402
|
+
const db = this.ensureOpen();
|
|
403
|
+
const limit = options?.limit ?? 50;
|
|
404
|
+
let sql = 'SELECT * FROM entities WHERE 1=1';
|
|
405
|
+
const params = [];
|
|
406
|
+
if (options?.maxConfidence !== undefined) {
|
|
407
|
+
sql += ' AND confidence <= ?';
|
|
408
|
+
params.push(options.maxConfidence);
|
|
409
|
+
}
|
|
410
|
+
if (options?.olderThan) {
|
|
411
|
+
sql += ' AND last_verified < ?';
|
|
412
|
+
params.push(options.olderThan);
|
|
413
|
+
}
|
|
414
|
+
sql += ' ORDER BY confidence ASC, last_verified ASC LIMIT ?';
|
|
415
|
+
params.push(limit);
|
|
416
|
+
const rows = db.prepare(sql).all(...params);
|
|
417
|
+
return rows.map(rowToEntity);
|
|
418
|
+
}
|
|
419
|
+
// ─── Export / Import ───────────────────────────────────────────
|
|
420
|
+
/**
|
|
421
|
+
* Export all entities and edges as a JSON-serializable structure.
|
|
422
|
+
*/
|
|
423
|
+
export() {
|
|
424
|
+
const db = this.ensureOpen();
|
|
425
|
+
const entityRows = db.prepare('SELECT * FROM entities').all();
|
|
426
|
+
const edgeRows = db.prepare('SELECT * FROM edges').all();
|
|
427
|
+
return {
|
|
428
|
+
entities: entityRows.map(rowToEntity),
|
|
429
|
+
edges: edgeRows.map(rowToEdge),
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Import entities and edges, skipping duplicates by ID.
|
|
434
|
+
*/
|
|
435
|
+
import(data) {
|
|
436
|
+
const db = this.ensureOpen();
|
|
437
|
+
let entitiesImported = 0;
|
|
438
|
+
let edgesImported = 0;
|
|
439
|
+
let entitiesSkipped = 0;
|
|
440
|
+
let edgesSkipped = 0;
|
|
441
|
+
const insertEntity = db.prepare(`
|
|
442
|
+
INSERT INTO entities (id, type, name, content, confidence, created_at, last_verified, last_accessed, expires_at, source, source_session, tags, domain)
|
|
443
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
444
|
+
`);
|
|
445
|
+
const insertEdge = db.prepare(`
|
|
446
|
+
INSERT INTO edges (id, from_id, to_id, relation, weight, context, created_at)
|
|
447
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
448
|
+
`);
|
|
449
|
+
const checkEntity = db.prepare('SELECT id FROM entities WHERE id = ?');
|
|
450
|
+
const checkEdge = db.prepare('SELECT id FROM edges WHERE id = ?');
|
|
451
|
+
const runImport = db.transaction(() => {
|
|
452
|
+
for (const entity of data.entities) {
|
|
453
|
+
if (checkEntity.get(entity.id)) {
|
|
454
|
+
entitiesSkipped++;
|
|
455
|
+
continue;
|
|
456
|
+
}
|
|
457
|
+
insertEntity.run(entity.id, entity.type, entity.name, entity.content, entity.confidence, entity.createdAt, entity.lastVerified, entity.lastAccessed, entity.expiresAt ?? null, entity.source, entity.sourceSession ?? null, JSON.stringify(entity.tags), entity.domain ?? null);
|
|
458
|
+
entitiesImported++;
|
|
459
|
+
}
|
|
460
|
+
for (const edge of data.edges) {
|
|
461
|
+
if (checkEdge.get(edge.id)) {
|
|
462
|
+
edgesSkipped++;
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
465
|
+
insertEdge.run(edge.id, edge.fromId, edge.toId, edge.relation, edge.weight, edge.context ?? null, edge.createdAt);
|
|
466
|
+
edgesImported++;
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
runImport();
|
|
470
|
+
return { entitiesImported, edgesImported, entitiesSkipped, edgesSkipped };
|
|
471
|
+
}
|
|
472
|
+
// ─── Statistics ─────────────────────────────────────────────────
|
|
473
|
+
/**
|
|
474
|
+
* Get aggregate statistics about the memory store.
|
|
475
|
+
*/
|
|
476
|
+
stats() {
|
|
477
|
+
const db = this.ensureOpen();
|
|
478
|
+
const entityCount = db.prepare('SELECT COUNT(*) as cnt FROM entities').get().cnt;
|
|
479
|
+
const edgeCount = db.prepare('SELECT COUNT(*) as cnt FROM edges').get().cnt;
|
|
480
|
+
// Count by type
|
|
481
|
+
const typeCounts = db.prepare('SELECT type, COUNT(*) as cnt FROM entities GROUP BY type').all();
|
|
482
|
+
const entityCountsByType = {};
|
|
483
|
+
for (const row of typeCounts) {
|
|
484
|
+
entityCountsByType[row.type] = row.cnt;
|
|
485
|
+
}
|
|
486
|
+
// Avg confidence
|
|
487
|
+
const avgRow = db.prepare('SELECT AVG(confidence) as avg FROM entities').get();
|
|
488
|
+
const avgConfidence = avgRow.avg ?? 0;
|
|
489
|
+
// Stale count
|
|
490
|
+
const staleCount = db.prepare('SELECT COUNT(*) as cnt FROM entities WHERE confidence < ?').get(this.config.staleThreshold).cnt;
|
|
491
|
+
// DB file size
|
|
492
|
+
let dbSizeBytes = 0;
|
|
493
|
+
try {
|
|
494
|
+
dbSizeBytes = fs.statSync(this.config.dbPath).size;
|
|
495
|
+
}
|
|
496
|
+
catch {
|
|
497
|
+
// File may not exist yet @silent-fallback-ok: stat before DB fully flushed
|
|
498
|
+
}
|
|
499
|
+
return {
|
|
500
|
+
totalEntities: entityCount,
|
|
501
|
+
totalEdges: edgeCount,
|
|
502
|
+
entityCountsByType: entityCountsByType,
|
|
503
|
+
avgConfidence: Math.round(avgConfidence * 100) / 100, // Round to 2 decimal places
|
|
504
|
+
staleCount,
|
|
505
|
+
dbSizeBytes,
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
// ─── Context Generation ─────────────────────────────────────────
|
|
509
|
+
/**
|
|
510
|
+
* Generate formatted markdown context for a query, suitable for session injection.
|
|
511
|
+
* Returns empty string if no relevant entities found.
|
|
512
|
+
*/
|
|
513
|
+
getRelevantContext(query, options) {
|
|
514
|
+
const maxTokens = options?.maxTokens ?? 2000;
|
|
515
|
+
const limit = options?.limit ?? 10;
|
|
516
|
+
const results = this.search(query, { limit });
|
|
517
|
+
if (results.length === 0)
|
|
518
|
+
return '';
|
|
519
|
+
const lines = [];
|
|
520
|
+
let estimatedTokens = 0;
|
|
521
|
+
for (const entity of results) {
|
|
522
|
+
const entry = `### ${entity.name} (${entity.type})\n${entity.content}\n`;
|
|
523
|
+
// Rough token estimate: ~0.75 tokens per word
|
|
524
|
+
const entryTokens = entry.split(/\s+/).length / 0.75;
|
|
525
|
+
if (estimatedTokens + entryTokens > maxTokens)
|
|
526
|
+
break;
|
|
527
|
+
lines.push(entry);
|
|
528
|
+
estimatedTokens += entryTokens;
|
|
529
|
+
}
|
|
530
|
+
return lines.join('\n');
|
|
531
|
+
}
|
|
532
|
+
// ─── Private Helpers ───────────────────────────────────────────
|
|
533
|
+
getConnections(db, entityId) {
|
|
534
|
+
const connections = [];
|
|
535
|
+
// Outgoing edges — use explicit column aliases to avoid JOIN collisions
|
|
536
|
+
const outgoing = db.prepare(`
|
|
537
|
+
SELECT
|
|
538
|
+
e.id as edge_id, e.from_id, e.to_id, e.relation, e.weight,
|
|
539
|
+
e.context as edge_context, e.created_at as edge_created_at,
|
|
540
|
+
ent.id as ent_id, ent.type, ent.name, ent.content, ent.confidence,
|
|
541
|
+
ent.created_at as ent_created_at, ent.last_verified, ent.last_accessed,
|
|
542
|
+
ent.expires_at, ent.source, ent.source_session, ent.tags, ent.domain
|
|
543
|
+
FROM edges e
|
|
544
|
+
JOIN entities ent ON ent.id = e.to_id
|
|
545
|
+
WHERE e.from_id = ?
|
|
546
|
+
`).all(entityId);
|
|
547
|
+
for (const row of outgoing) {
|
|
548
|
+
connections.push({
|
|
549
|
+
entity: joinRowToEntity(row),
|
|
550
|
+
edge: joinRowToEdge(row),
|
|
551
|
+
direction: 'outgoing',
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
// Incoming edges
|
|
555
|
+
const incoming = db.prepare(`
|
|
556
|
+
SELECT
|
|
557
|
+
e.id as edge_id, e.from_id, e.to_id, e.relation, e.weight,
|
|
558
|
+
e.context as edge_context, e.created_at as edge_created_at,
|
|
559
|
+
ent.id as ent_id, ent.type, ent.name, ent.content, ent.confidence,
|
|
560
|
+
ent.created_at as ent_created_at, ent.last_verified, ent.last_accessed,
|
|
561
|
+
ent.expires_at, ent.source, ent.source_session, ent.tags, ent.domain
|
|
562
|
+
FROM edges e
|
|
563
|
+
JOIN entities ent ON ent.id = e.from_id
|
|
564
|
+
WHERE e.to_id = ?
|
|
565
|
+
`).all(entityId);
|
|
566
|
+
for (const row of incoming) {
|
|
567
|
+
connections.push({
|
|
568
|
+
entity: joinRowToEntity(row),
|
|
569
|
+
edge: joinRowToEdge(row),
|
|
570
|
+
direction: 'incoming',
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
return connections;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
// ─── Converters ─────────────────────────────────────────────────
|
|
577
|
+
function rowToEntity(row) {
|
|
578
|
+
return {
|
|
579
|
+
id: row.id,
|
|
580
|
+
type: row.type,
|
|
581
|
+
name: row.name,
|
|
582
|
+
content: row.content,
|
|
583
|
+
confidence: row.confidence,
|
|
584
|
+
createdAt: row.created_at,
|
|
585
|
+
lastVerified: row.last_verified,
|
|
586
|
+
lastAccessed: row.last_accessed,
|
|
587
|
+
expiresAt: row.expires_at ?? undefined,
|
|
588
|
+
source: row.source,
|
|
589
|
+
sourceSession: row.source_session ?? undefined,
|
|
590
|
+
tags: JSON.parse(row.tags),
|
|
591
|
+
domain: row.domain ?? undefined,
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
function rowToEdge(row) {
|
|
595
|
+
return {
|
|
596
|
+
id: row.id,
|
|
597
|
+
fromId: row.from_id,
|
|
598
|
+
toId: row.to_id,
|
|
599
|
+
relation: row.relation,
|
|
600
|
+
weight: row.weight,
|
|
601
|
+
context: row.context ?? undefined,
|
|
602
|
+
createdAt: row.created_at,
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
/** Convert a JOIN row (with explicit aliases) to a MemoryEntity */
|
|
606
|
+
function joinRowToEntity(row) {
|
|
607
|
+
return {
|
|
608
|
+
id: row.ent_id,
|
|
609
|
+
type: row.type,
|
|
610
|
+
name: row.name,
|
|
611
|
+
content: row.content,
|
|
612
|
+
confidence: row.confidence,
|
|
613
|
+
createdAt: row.ent_created_at,
|
|
614
|
+
lastVerified: row.last_verified,
|
|
615
|
+
lastAccessed: row.last_accessed,
|
|
616
|
+
expiresAt: row.expires_at ?? undefined,
|
|
617
|
+
source: row.source,
|
|
618
|
+
sourceSession: row.source_session ?? undefined,
|
|
619
|
+
tags: JSON.parse(row.tags),
|
|
620
|
+
domain: row.domain ?? undefined,
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
/** Convert a JOIN row (with explicit aliases) to a MemoryEdge */
|
|
624
|
+
function joinRowToEdge(row) {
|
|
625
|
+
return {
|
|
626
|
+
id: row.edge_id,
|
|
627
|
+
fromId: row.from_id,
|
|
628
|
+
toId: row.to_id,
|
|
629
|
+
relation: row.relation,
|
|
630
|
+
weight: row.weight,
|
|
631
|
+
context: row.edge_context ?? undefined,
|
|
632
|
+
createdAt: row.edge_created_at,
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
//# sourceMappingURL=SemanticMemory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SemanticMemory.js","sourceRoot":"","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AAE,GAAG,CAAC,OAAO;QACnB,IAAI,EAAE,GAAG,CAAC,KAAK;QACf,QAAQ,EAAE,GAAG,CAAC,QAAwB;QACtC,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,OAAO,EAAE,GAAG,CAAC,YAAY,IAAI,SAAS;QACtC,SAAS,EAAE,GAAG,CAAC,eAAe;KAC/B,CAAC;AACJ,CAAC"}
|
|
@@ -67,6 +67,7 @@ export declare class AgentServer {
|
|
|
67
67
|
adaptiveTrust?: import('../core/AdaptiveTrust.js').AdaptiveTrust;
|
|
68
68
|
memoryMonitor?: import('../monitoring/MemoryPressureMonitor.js').MemoryPressureMonitor;
|
|
69
69
|
orphanReaper?: import('../monitoring/OrphanProcessReaper.js').OrphanProcessReaper;
|
|
70
|
+
semanticMemory?: import('../memory/SemanticMemory.js').SemanticMemory;
|
|
70
71
|
coordinator?: MultiMachineCoordinator;
|
|
71
72
|
localSigningKeyPem?: string;
|
|
72
73
|
});
|