nodebench-mcp 2.32.0 → 2.34.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.
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Providers barrel export — Ambient Intelligence Layer.
3
+ *
4
+ * Re-exports all memory provider interfaces, implementations, and the registry.
5
+ */
6
+ export type { MemoryProvider, ProviderType, ProviderConfig, MemoryInput, Memory, MemoryRelation, RelationType, StoredRelation, RecallOptions, ListOptions, UserProfile, SyncResult, } from "./memoryProvider.js";
7
+ export { LocalMemoryProvider } from "./localMemoryProvider.js";
8
+ export { SupermemoryProvider, SupermemoryError, SupermemoryAuthError, SupermemoryRateLimitError, } from "./supermemoryProvider.js";
9
+ export { MemoryProviderRegistry } from "./memoryProviderRegistry.js";
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Providers barrel export — Ambient Intelligence Layer.
3
+ *
4
+ * Re-exports all memory provider interfaces, implementations, and the registry.
5
+ */
6
+ // Local SQLite implementation
7
+ export { LocalMemoryProvider } from "./localMemoryProvider.js";
8
+ // Supermemory cloud implementation
9
+ export { SupermemoryProvider, SupermemoryError, SupermemoryAuthError, SupermemoryRateLimitError, } from "./supermemoryProvider.js";
10
+ // Singleton registry
11
+ export { MemoryProviderRegistry } from "./memoryProviderRegistry.js";
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAkBH,8BAA8B;AAC9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,mCAAmC;AACnC,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,0BAA0B,CAAC;AAElC,qBAAqB;AACrB,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * LocalMemoryProvider — SQLite-backed MemoryProvider implementation.
3
+ *
4
+ * Uses the existing NodeBench SQLite database (via getDb()) with FTS5
5
+ * for full-text recall. All data stays local on disk at ~/.nodebench/nodebench.db.
6
+ *
7
+ * Tables created on connect:
8
+ * - memory_items — core memory storage
9
+ * - memory_items_fts — FTS5 virtual table for search
10
+ * - memory_relations — directed edges between memories
11
+ * - memory_profiles — cached user profile aggregates (optional)
12
+ *
13
+ * Follows the same schema patterns as db.ts (triggers for FTS sync, indexes).
14
+ */
15
+ import type { MemoryProvider, ProviderConfig, MemoryInput, Memory, MemoryRelation, RecallOptions, ListOptions, UserProfile, SyncResult } from "./memoryProvider.js";
16
+ export declare class LocalMemoryProvider implements MemoryProvider {
17
+ readonly name = "local-sqlite";
18
+ readonly type: "local";
19
+ private db;
20
+ private config;
21
+ private connected;
22
+ connect(config: ProviderConfig): Promise<void>;
23
+ disconnect(): Promise<void>;
24
+ isConnected(): boolean;
25
+ private ensureConnected;
26
+ store(memory: MemoryInput): Promise<string>;
27
+ update(id: string, memory: MemoryInput): Promise<void>;
28
+ delete(id: string): Promise<void>;
29
+ recall(query: string, options?: RecallOptions): Promise<Memory[]>;
30
+ get(id: string): Promise<Memory | null>;
31
+ list(options?: ListOptions): Promise<Memory[]>;
32
+ relate(fromId: string, toId: string, relation: MemoryRelation): Promise<void>;
33
+ getProfile(userId?: string): Promise<UserProfile | null>;
34
+ sync(direction: "push" | "pull" | "both"): Promise<SyncResult>;
35
+ }
@@ -0,0 +1,370 @@
1
+ /**
2
+ * LocalMemoryProvider — SQLite-backed MemoryProvider implementation.
3
+ *
4
+ * Uses the existing NodeBench SQLite database (via getDb()) with FTS5
5
+ * for full-text recall. All data stays local on disk at ~/.nodebench/nodebench.db.
6
+ *
7
+ * Tables created on connect:
8
+ * - memory_items — core memory storage
9
+ * - memory_items_fts — FTS5 virtual table for search
10
+ * - memory_relations — directed edges between memories
11
+ * - memory_profiles — cached user profile aggregates (optional)
12
+ *
13
+ * Follows the same schema patterns as db.ts (triggers for FTS sync, indexes).
14
+ */
15
+ import { randomUUID } from "node:crypto";
16
+ import { getDb } from "../db.js";
17
+ // ═══════════════════════════════════════════════════════════════════════════
18
+ // Schema SQL — executed once on connect
19
+ // ═══════════════════════════════════════════════════════════════════════════
20
+ const MEMORY_SCHEMA_SQL = `
21
+ -- Core memory storage
22
+ CREATE TABLE IF NOT EXISTS memory_items (
23
+ id TEXT PRIMARY KEY,
24
+ content TEXT NOT NULL,
25
+ metadata TEXT NOT NULL DEFAULT '{}',
26
+ scope TEXT NOT NULL DEFAULT 'general',
27
+ tags TEXT NOT NULL DEFAULT '[]',
28
+ source TEXT NOT NULL DEFAULT '',
29
+ user_id TEXT NOT NULL DEFAULT 'default',
30
+ created_at TEXT NOT NULL DEFAULT (datetime('now')),
31
+ updated_at TEXT NOT NULL DEFAULT (datetime('now'))
32
+ );
33
+
34
+ CREATE INDEX IF NOT EXISTS idx_memory_items_scope ON memory_items(scope);
35
+ CREATE INDEX IF NOT EXISTS idx_memory_items_source ON memory_items(source);
36
+ CREATE INDEX IF NOT EXISTS idx_memory_items_user ON memory_items(user_id);
37
+ CREATE INDEX IF NOT EXISTS idx_memory_items_created ON memory_items(created_at);
38
+
39
+ -- FTS5 for full-text search
40
+ CREATE VIRTUAL TABLE IF NOT EXISTS memory_items_fts USING fts5(
41
+ content,
42
+ scope,
43
+ tags,
44
+ source,
45
+ content='memory_items',
46
+ content_rowid='rowid'
47
+ );
48
+
49
+ CREATE TRIGGER IF NOT EXISTS memory_items_fts_insert AFTER INSERT ON memory_items BEGIN
50
+ INSERT INTO memory_items_fts(rowid, content, scope, tags, source)
51
+ VALUES (new.rowid, new.content, new.scope, new.tags, new.source);
52
+ END;
53
+
54
+ CREATE TRIGGER IF NOT EXISTS memory_items_fts_delete AFTER DELETE ON memory_items BEGIN
55
+ INSERT INTO memory_items_fts(memory_items_fts, rowid, content, scope, tags, source)
56
+ VALUES ('delete', old.rowid, old.content, old.scope, old.tags, old.source);
57
+ END;
58
+
59
+ CREATE TRIGGER IF NOT EXISTS memory_items_fts_update AFTER UPDATE ON memory_items BEGIN
60
+ INSERT INTO memory_items_fts(memory_items_fts, rowid, content, scope, tags, source)
61
+ VALUES ('delete', old.rowid, old.content, old.scope, old.tags, old.source);
62
+ INSERT INTO memory_items_fts(rowid, content, scope, tags, source)
63
+ VALUES (new.rowid, new.content, new.scope, new.tags, new.source);
64
+ END;
65
+
66
+ -- Directed relations between memories
67
+ CREATE TABLE IF NOT EXISTS memory_relations (
68
+ id TEXT PRIMARY KEY,
69
+ from_id TEXT NOT NULL REFERENCES memory_items(id) ON DELETE CASCADE,
70
+ to_id TEXT NOT NULL REFERENCES memory_items(id) ON DELETE CASCADE,
71
+ type TEXT NOT NULL,
72
+ label TEXT,
73
+ confidence REAL DEFAULT 1.0,
74
+ metadata TEXT NOT NULL DEFAULT '{}',
75
+ created_at TEXT NOT NULL DEFAULT (datetime('now')),
76
+ UNIQUE(from_id, to_id, type)
77
+ );
78
+
79
+ CREATE INDEX IF NOT EXISTS idx_memory_relations_from ON memory_relations(from_id);
80
+ CREATE INDEX IF NOT EXISTS idx_memory_relations_to ON memory_relations(to_id);
81
+ CREATE INDEX IF NOT EXISTS idx_memory_relations_type ON memory_relations(type);
82
+ `;
83
+ function rowToMemory(row, relevanceScore) {
84
+ let metadata = {};
85
+ try {
86
+ metadata = JSON.parse(row.metadata);
87
+ }
88
+ catch { /* keep empty */ }
89
+ let tags = [];
90
+ try {
91
+ tags = JSON.parse(row.tags);
92
+ }
93
+ catch { /* keep empty */ }
94
+ return {
95
+ id: row.id,
96
+ content: row.content,
97
+ metadata,
98
+ scope: row.scope,
99
+ tags,
100
+ source: row.source,
101
+ userId: row.user_id,
102
+ createdAt: row.created_at,
103
+ updatedAt: row.updated_at,
104
+ ...(relevanceScore !== undefined ? { relevanceScore } : {}),
105
+ };
106
+ }
107
+ // ═══════════════════════════════════════════════════════════════════════════
108
+ // LocalMemoryProvider
109
+ // ═══════════════════════════════════════════════════════════════════════════
110
+ export class LocalMemoryProvider {
111
+ name = "local-sqlite";
112
+ type = "local";
113
+ db = null;
114
+ config = {};
115
+ connected = false;
116
+ // ── Lifecycle ──────────────────────────────────────────────────────────
117
+ async connect(config) {
118
+ this.config = config;
119
+ this.db = getDb();
120
+ this.db.exec(MEMORY_SCHEMA_SQL);
121
+ this.connected = true;
122
+ }
123
+ async disconnect() {
124
+ // We don't close the shared DB — other modules use it.
125
+ // Just mark ourselves as disconnected.
126
+ this.connected = false;
127
+ this.db = null;
128
+ }
129
+ isConnected() {
130
+ return this.connected && this.db !== null;
131
+ }
132
+ ensureConnected() {
133
+ if (!this.db || !this.connected) {
134
+ throw new Error("LocalMemoryProvider is not connected — call connect() first");
135
+ }
136
+ return this.db;
137
+ }
138
+ // ── CRUD ───────────────────────────────────────────────────────────────
139
+ async store(memory) {
140
+ const db = this.ensureConnected();
141
+ const id = randomUUID();
142
+ const now = new Date().toISOString();
143
+ const userId = memory.userId ?? this.config.userId ?? "default";
144
+ db.prepare(`
145
+ INSERT INTO memory_items (id, content, metadata, scope, tags, source, user_id, created_at, updated_at)
146
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
147
+ `).run(id, memory.content, JSON.stringify(memory.metadata ?? {}), memory.scope ?? "general", JSON.stringify(memory.tags ?? []), memory.source ?? "", userId, memory.timestamp ?? now, now);
148
+ return id;
149
+ }
150
+ async update(id, memory) {
151
+ const db = this.ensureConnected();
152
+ const now = new Date().toISOString();
153
+ const existing = db.prepare("SELECT id FROM memory_items WHERE id = ?").get(id);
154
+ if (!existing) {
155
+ throw new Error(`Memory not found: ${id}`);
156
+ }
157
+ db.prepare(`
158
+ UPDATE memory_items
159
+ SET content = ?, metadata = ?, scope = ?, tags = ?, source = ?, updated_at = ?
160
+ WHERE id = ?
161
+ `).run(memory.content, JSON.stringify(memory.metadata ?? {}), memory.scope ?? "general", JSON.stringify(memory.tags ?? []), memory.source ?? "", now, id);
162
+ }
163
+ async delete(id) {
164
+ const db = this.ensureConnected();
165
+ const result = db.prepare("DELETE FROM memory_items WHERE id = ?").run(id);
166
+ if (result.changes === 0) {
167
+ throw new Error(`Memory not found: ${id}`);
168
+ }
169
+ }
170
+ // ── Retrieval ──────────────────────────────────────────────────────────
171
+ async recall(query, options) {
172
+ const db = this.ensureConnected();
173
+ const limit = options?.limit ?? 10;
174
+ // Build FTS5 query — escape special characters for safety
175
+ const safeQuery = query
176
+ .replace(/['"]/g, " ")
177
+ .replace(/[^\w\s-]/g, " ")
178
+ .trim();
179
+ if (!safeQuery)
180
+ return [];
181
+ // FTS5 search with BM25 ranking
182
+ const whereClauses = [];
183
+ const params = [];
184
+ // Base FTS match
185
+ const ftsQuery = safeQuery
186
+ .split(/\s+/)
187
+ .filter((w) => w.length > 0)
188
+ .map((w) => `"${w}"`)
189
+ .join(" OR ");
190
+ if (!ftsQuery)
191
+ return [];
192
+ // Optional filters applied as post-filter on joined rows
193
+ let filterSql = "";
194
+ if (options?.scope) {
195
+ whereClauses.push("m.scope = ?");
196
+ params.push(options.scope);
197
+ }
198
+ if (options?.source) {
199
+ whereClauses.push("m.source = ?");
200
+ params.push(options.source);
201
+ }
202
+ if (options?.userId) {
203
+ whereClauses.push("m.user_id = ?");
204
+ params.push(options.userId);
205
+ }
206
+ else if (this.config.userId) {
207
+ whereClauses.push("m.user_id = ?");
208
+ params.push(this.config.userId);
209
+ }
210
+ if (options?.after) {
211
+ whereClauses.push("m.created_at > ?");
212
+ params.push(options.after);
213
+ }
214
+ if (options?.before) {
215
+ whereClauses.push("m.created_at < ?");
216
+ params.push(options.before);
217
+ }
218
+ if (whereClauses.length > 0) {
219
+ filterSql = " AND " + whereClauses.join(" AND ");
220
+ }
221
+ const sql = `
222
+ SELECT m.*, rank
223
+ FROM memory_items_fts fts
224
+ JOIN memory_items m ON m.rowid = fts.rowid
225
+ WHERE memory_items_fts MATCH ?${filterSql}
226
+ ORDER BY rank
227
+ LIMIT ?
228
+ `;
229
+ const rows = db.prepare(sql).all(ftsQuery, ...params, limit);
230
+ // Normalize BM25 rank to 0-1 relevance score
231
+ const maxRank = rows.length > 0
232
+ ? Math.max(...rows.map((r) => Math.abs(r.rank ?? 0)), 1)
233
+ : 1;
234
+ const results = rows.map((row) => {
235
+ const absRank = Math.abs(row.rank ?? 0);
236
+ const score = maxRank > 0 ? absRank / maxRank : 0;
237
+ return rowToMemory(row, score);
238
+ });
239
+ // Post-filter by tags if specified
240
+ if (options?.tags && options.tags.length > 0) {
241
+ const tagSet = new Set(options.tags);
242
+ return results.filter((m) => m.tags.some((t) => tagSet.has(t)));
243
+ }
244
+ // Post-filter by minScore
245
+ if (options?.minScore !== undefined) {
246
+ return results.filter((m) => (m.relevanceScore ?? 0) >= (options.minScore ?? 0));
247
+ }
248
+ return results;
249
+ }
250
+ async get(id) {
251
+ const db = this.ensureConnected();
252
+ const row = db.prepare("SELECT * FROM memory_items WHERE id = ?").get(id);
253
+ return row ? rowToMemory(row) : null;
254
+ }
255
+ async list(options) {
256
+ const db = this.ensureConnected();
257
+ const limit = options?.limit ?? 50;
258
+ const offset = options?.offset ?? 0;
259
+ const orderBy = options?.orderBy === "updatedAt"
260
+ ? "updated_at"
261
+ : "created_at";
262
+ const direction = options?.orderDirection === "asc" ? "ASC" : "DESC";
263
+ const whereClauses = [];
264
+ const params = [];
265
+ if (options?.scope) {
266
+ whereClauses.push("scope = ?");
267
+ params.push(options.scope);
268
+ }
269
+ if (options?.source) {
270
+ whereClauses.push("source = ?");
271
+ params.push(options.source);
272
+ }
273
+ if (options?.userId) {
274
+ whereClauses.push("user_id = ?");
275
+ params.push(options.userId);
276
+ }
277
+ else if (this.config.userId) {
278
+ whereClauses.push("user_id = ?");
279
+ params.push(this.config.userId);
280
+ }
281
+ const whereClause = whereClauses.length > 0 ? "WHERE " + whereClauses.join(" AND ") : "";
282
+ const sql = `
283
+ SELECT * FROM memory_items
284
+ ${whereClause}
285
+ ORDER BY ${orderBy} ${direction}
286
+ LIMIT ? OFFSET ?
287
+ `;
288
+ const rows = db.prepare(sql).all(...params, limit, offset);
289
+ let results = rows.map((row) => rowToMemory(row));
290
+ // Post-filter by tags if specified
291
+ if (options?.tags && options.tags.length > 0) {
292
+ const tagSet = new Set(options.tags);
293
+ results = results.filter((m) => m.tags.some((t) => tagSet.has(t)));
294
+ }
295
+ return results;
296
+ }
297
+ // ── Relations ──────────────────────────────────────────────────────────
298
+ async relate(fromId, toId, relation) {
299
+ const db = this.ensureConnected();
300
+ const id = randomUUID();
301
+ // Verify both memories exist
302
+ const fromExists = db.prepare("SELECT id FROM memory_items WHERE id = ?").get(fromId);
303
+ const toExists = db.prepare("SELECT id FROM memory_items WHERE id = ?").get(toId);
304
+ if (!fromExists)
305
+ throw new Error(`Source memory not found: ${fromId}`);
306
+ if (!toExists)
307
+ throw new Error(`Target memory not found: ${toId}`);
308
+ db.prepare(`
309
+ INSERT OR REPLACE INTO memory_relations (id, from_id, to_id, type, label, confidence, metadata, created_at)
310
+ VALUES (?, ?, ?, ?, ?, ?, ?, datetime('now'))
311
+ `).run(id, fromId, toId, relation.type, relation.label ?? null, relation.confidence ?? 1.0, JSON.stringify(relation.metadata ?? {}));
312
+ }
313
+ // ── Profile ────────────────────────────────────────────────────────────
314
+ async getProfile(userId) {
315
+ const db = this.ensureConnected();
316
+ const uid = userId ?? this.config.userId ?? "default";
317
+ const countRow = db.prepare("SELECT COUNT(*) as c FROM memory_items WHERE user_id = ?").get(uid);
318
+ if (countRow.c === 0)
319
+ return null;
320
+ const scopeRows = db.prepare("SELECT DISTINCT scope FROM memory_items WHERE user_id = ?").all(uid);
321
+ const firstRow = db.prepare("SELECT created_at FROM memory_items WHERE user_id = ? ORDER BY created_at ASC LIMIT 1").get(uid);
322
+ const lastRow = db.prepare("SELECT created_at FROM memory_items WHERE user_id = ? ORDER BY created_at DESC LIMIT 1").get(uid);
323
+ // Aggregate tags — parse JSON arrays and count
324
+ const allRows = db.prepare("SELECT tags, source FROM memory_items WHERE user_id = ?").all(uid);
325
+ const tagCounts = new Map();
326
+ const sourceCounts = new Map();
327
+ for (const row of allRows) {
328
+ try {
329
+ const tags = JSON.parse(row.tags);
330
+ for (const tag of tags) {
331
+ tagCounts.set(tag, (tagCounts.get(tag) ?? 0) + 1);
332
+ }
333
+ }
334
+ catch { /* skip malformed */ }
335
+ if (row.source) {
336
+ sourceCounts.set(row.source, (sourceCounts.get(row.source) ?? 0) + 1);
337
+ }
338
+ }
339
+ const topTags = [...tagCounts.entries()]
340
+ .sort((a, b) => b[1] - a[1])
341
+ .slice(0, 10)
342
+ .map(([tag, count]) => ({ tag, count }));
343
+ const topSources = [...sourceCounts.entries()]
344
+ .sort((a, b) => b[1] - a[1])
345
+ .slice(0, 10)
346
+ .map(([source, count]) => ({ source, count }));
347
+ return {
348
+ userId: uid,
349
+ memoryCount: countRow.c,
350
+ scopes: scopeRows.map((r) => r.scope),
351
+ topTags,
352
+ topSources,
353
+ firstMemoryAt: firstRow?.created_at ?? null,
354
+ lastMemoryAt: lastRow?.created_at ?? null,
355
+ };
356
+ }
357
+ // ── Sync ───────────────────────────────────────────────────────────────
358
+ async sync(direction) {
359
+ // Local provider — no remote to sync with. Return no-op result.
360
+ return {
361
+ direction,
362
+ pushed: 0,
363
+ pulled: 0,
364
+ conflicts: 0,
365
+ errors: 0,
366
+ completedAt: new Date().toISOString(),
367
+ };
368
+ }
369
+ }
370
+ //# sourceMappingURL=localMemoryProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localMemoryProvider.js","sourceRoot":"","sources":["../../src/providers/localMemoryProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAcjC,8EAA8E;AAC9E,wCAAwC;AACxC,8EAA8E;AAE9E,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;QAEjD,OAAO;YACL,MAAM,EAAE,GAAG;YACX,WAAW,EAAE,QAAQ,CAAC,CAAC;YACvB,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;YACrC,OAAO;YACP,UAAU;YACV,aAAa,EAAE,QAAQ,EAAE,UAAU,IAAI,IAAI;YAC3C,YAAY,EAAE,OAAO,EAAE,UAAU,IAAI,IAAI;SAC1C,CAAC;IACJ,CAAC;IAED,0EAA0E;IAE1E,KAAK,CAAC,IAAI,CAAC,SAAmC;QAC5C,gEAAgE;QAChE,OAAO;YACL,SAAS;YACT,MAAM,EAAE,CAAC;YACT,MAAM,EAAE,CAAC;YACT,SAAS,EAAE,CAAC;YACZ,MAAM,EAAE,CAAC;YACT,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACtC,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,187 @@
1
+ /**
2
+ * MemoryProvider — Abstract interface for NodeBench's Ambient Intelligence Layer.
3
+ *
4
+ * Defines the contract that all memory providers (local SQLite, Supermemory,
5
+ * Zep, Graphiti, custom) must implement. Enables multi-provider memory
6
+ * with unified recall, relation graphs, user profiles, and bidirectional sync.
7
+ *
8
+ * Design principles:
9
+ * - Every provider is independently usable (store/recall/relate)
10
+ * - Sync is optional — local-first providers may no-op
11
+ * - Relations form an entity graph across memories
12
+ * - Profiles aggregate user-level context from memories
13
+ */
14
+ export type ProviderType = "supermemory" | "local" | "zep" | "graphiti" | "custom";
15
+ export interface ProviderConfig {
16
+ /** Provider-specific API key or token */
17
+ apiKey?: string;
18
+ /** Base URL for remote providers */
19
+ baseUrl?: string;
20
+ /** User ID scope (isolates memories per user) */
21
+ userId?: string;
22
+ /** Additional provider-specific settings */
23
+ options?: Record<string, unknown>;
24
+ }
25
+ export interface MemoryInput {
26
+ /** Raw content to store */
27
+ content: string;
28
+ /** Optional structured metadata */
29
+ metadata?: Record<string, unknown>;
30
+ /** Categorization scope (e.g. "project", "entity", "decision", "conversation") */
31
+ scope?: string;
32
+ /** Tags for filtering and grouping */
33
+ tags?: string[];
34
+ /** Source identifier (e.g. tool name, agent ID, session ID) */
35
+ source?: string;
36
+ /** ISO 8601 timestamp override (defaults to now) */
37
+ timestamp?: string;
38
+ /** Optional user ID (defaults to provider config userId) */
39
+ userId?: string;
40
+ }
41
+ export interface Memory {
42
+ /** Unique memory ID (provider-generated) */
43
+ id: string;
44
+ /** Raw content */
45
+ content: string;
46
+ /** Structured metadata */
47
+ metadata: Record<string, unknown>;
48
+ /** Categorization scope */
49
+ scope: string;
50
+ /** Tags */
51
+ tags: string[];
52
+ /** Source identifier */
53
+ source: string;
54
+ /** User ID that owns this memory */
55
+ userId: string;
56
+ /** ISO 8601 creation timestamp */
57
+ createdAt: string;
58
+ /** ISO 8601 last-update timestamp */
59
+ updatedAt: string;
60
+ /** Relevance score (0-1, set during recall) */
61
+ relevanceScore?: number;
62
+ }
63
+ export type RelationType = "related_to" | "caused_by" | "supports" | "contradicts" | "follows" | "references" | "part_of" | "derived_from";
64
+ export interface MemoryRelation {
65
+ /** Relation type */
66
+ type: RelationType;
67
+ /** Optional human-readable label */
68
+ label?: string;
69
+ /** Confidence score (0-1) */
70
+ confidence?: number;
71
+ /** Additional relation metadata */
72
+ metadata?: Record<string, unknown>;
73
+ }
74
+ export interface StoredRelation extends MemoryRelation {
75
+ /** Unique relation ID */
76
+ id: string;
77
+ /** Source memory ID */
78
+ fromId: string;
79
+ /** Target memory ID */
80
+ toId: string;
81
+ /** ISO 8601 creation timestamp */
82
+ createdAt: string;
83
+ }
84
+ export interface RecallOptions {
85
+ /** Maximum results to return (default: 10) */
86
+ limit?: number;
87
+ /** Filter by scope */
88
+ scope?: string;
89
+ /** Filter by tags (any match) */
90
+ tags?: string[];
91
+ /** Filter by source */
92
+ source?: string;
93
+ /** Filter by user ID */
94
+ userId?: string;
95
+ /** Minimum relevance score (0-1) for semantic search */
96
+ minScore?: number;
97
+ /** ISO 8601 — only memories after this date */
98
+ after?: string;
99
+ /** ISO 8601 — only memories before this date */
100
+ before?: string;
101
+ }
102
+ export interface ListOptions {
103
+ /** Maximum results (default: 50) */
104
+ limit?: number;
105
+ /** Offset for pagination */
106
+ offset?: number;
107
+ /** Filter by scope */
108
+ scope?: string;
109
+ /** Filter by tags (any match) */
110
+ tags?: string[];
111
+ /** Filter by source */
112
+ source?: string;
113
+ /** Filter by user ID */
114
+ userId?: string;
115
+ /** Sort order */
116
+ orderBy?: "createdAt" | "updatedAt" | "relevanceScore";
117
+ /** Sort direction */
118
+ orderDirection?: "asc" | "desc";
119
+ }
120
+ export interface UserProfile {
121
+ /** User ID */
122
+ userId: string;
123
+ /** Total memory count for this user */
124
+ memoryCount: number;
125
+ /** Scopes used by this user */
126
+ scopes: string[];
127
+ /** Most used tags */
128
+ topTags: Array<{
129
+ tag: string;
130
+ count: number;
131
+ }>;
132
+ /** Most active sources */
133
+ topSources: Array<{
134
+ source: string;
135
+ count: number;
136
+ }>;
137
+ /** ISO 8601 timestamp of earliest memory */
138
+ firstMemoryAt: string | null;
139
+ /** ISO 8601 timestamp of most recent memory */
140
+ lastMemoryAt: string | null;
141
+ }
142
+ export interface SyncResult {
143
+ /** Sync direction that was executed */
144
+ direction: "push" | "pull" | "both";
145
+ /** Number of memories pushed to remote */
146
+ pushed: number;
147
+ /** Number of memories pulled from remote */
148
+ pulled: number;
149
+ /** Number of conflicts detected */
150
+ conflicts: number;
151
+ /** Number of errors during sync */
152
+ errors: number;
153
+ /** ISO 8601 timestamp of sync completion */
154
+ completedAt: string;
155
+ /** Error details if any */
156
+ errorDetails?: string[];
157
+ }
158
+ export interface MemoryProvider {
159
+ /** Human-readable provider name (e.g. "local-sqlite", "supermemory") */
160
+ readonly name: string;
161
+ /** Provider type for registry classification */
162
+ readonly type: ProviderType;
163
+ /** Initialize connection to the provider backend */
164
+ connect(config: ProviderConfig): Promise<void>;
165
+ /** Gracefully disconnect from the provider backend */
166
+ disconnect(): Promise<void>;
167
+ /** Check if the provider is currently connected and operational */
168
+ isConnected(): boolean;
169
+ /** Store a new memory. Returns the generated memory ID. */
170
+ store(memory: MemoryInput): Promise<string>;
171
+ /** Update an existing memory by ID. */
172
+ update(id: string, memory: MemoryInput): Promise<void>;
173
+ /** Delete a memory by ID. */
174
+ delete(id: string): Promise<void>;
175
+ /** Semantic/keyword recall — search memories by natural language query. */
176
+ recall(query: string, options?: RecallOptions): Promise<Memory[]>;
177
+ /** Get a single memory by ID. Returns null if not found. */
178
+ get(id: string): Promise<Memory | null>;
179
+ /** List memories with filtering and pagination. */
180
+ list(options?: ListOptions): Promise<Memory[]>;
181
+ /** Create a directed relation between two memories. */
182
+ relate(fromId: string, toId: string, relation: MemoryRelation): Promise<void>;
183
+ /** Get aggregated profile for a user. Uses provider config userId if omitted. */
184
+ getProfile(userId?: string): Promise<UserProfile | null>;
185
+ /** Synchronize memories with a remote backend. */
186
+ sync(direction: "push" | "pull" | "both"): Promise<SyncResult>;
187
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * MemoryProvider — Abstract interface for NodeBench's Ambient Intelligence Layer.
3
+ *
4
+ * Defines the contract that all memory providers (local SQLite, Supermemory,
5
+ * Zep, Graphiti, custom) must implement. Enables multi-provider memory
6
+ * with unified recall, relation graphs, user profiles, and bidirectional sync.
7
+ *
8
+ * Design principles:
9
+ * - Every provider is independently usable (store/recall/relate)
10
+ * - Sync is optional — local-first providers may no-op
11
+ * - Relations form an entity graph across memories
12
+ * - Profiles aggregate user-level context from memories
13
+ */
14
+ export {};
15
+ //# sourceMappingURL=memoryProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memoryProvider.js","sourceRoot":"","sources":["../../src/providers/memoryProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}