moflo 4.0.2 → 4.0.4

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.
Files changed (90) hide show
  1. package/package.json +114 -110
  2. package/v3/@claude-flow/cli/dist/src/commands/hooks.js +4 -1
  3. package/v3/@claude-flow/cli/dist/src/memory/memory-bridge.js +61 -5
  4. package/v3/@claude-flow/cli/dist/src/memory/memory-initializer.js +1892 -1841
  5. package/v3/@claude-flow/memory/README.md +587 -0
  6. package/v3/@claude-flow/memory/dist/agent-memory-scope.d.ts +131 -0
  7. package/v3/@claude-flow/memory/dist/agent-memory-scope.js +223 -0
  8. package/v3/@claude-flow/memory/dist/agent-memory-scope.test.d.ts +8 -0
  9. package/v3/@claude-flow/memory/dist/agent-memory-scope.test.js +463 -0
  10. package/v3/@claude-flow/memory/dist/agentdb-adapter.d.ts +165 -0
  11. package/v3/@claude-flow/memory/dist/agentdb-adapter.js +806 -0
  12. package/v3/@claude-flow/memory/dist/agentdb-backend.d.ts +214 -0
  13. package/v3/@claude-flow/memory/dist/agentdb-backend.js +844 -0
  14. package/v3/@claude-flow/memory/dist/agentdb-backend.test.d.ts +7 -0
  15. package/v3/@claude-flow/memory/dist/agentdb-backend.test.js +258 -0
  16. package/v3/@claude-flow/memory/dist/application/commands/delete-memory.command.d.ts +65 -0
  17. package/v3/@claude-flow/memory/dist/application/commands/delete-memory.command.js +129 -0
  18. package/v3/@claude-flow/memory/dist/application/commands/store-memory.command.d.ts +48 -0
  19. package/v3/@claude-flow/memory/dist/application/commands/store-memory.command.js +72 -0
  20. package/v3/@claude-flow/memory/dist/application/index.d.ts +12 -0
  21. package/v3/@claude-flow/memory/dist/application/index.js +15 -0
  22. package/v3/@claude-flow/memory/dist/application/queries/search-memory.query.d.ts +72 -0
  23. package/v3/@claude-flow/memory/dist/application/queries/search-memory.query.js +143 -0
  24. package/v3/@claude-flow/memory/dist/application/services/memory-application-service.d.ts +121 -0
  25. package/v3/@claude-flow/memory/dist/application/services/memory-application-service.js +190 -0
  26. package/v3/@claude-flow/memory/dist/auto-memory-bridge.d.ts +226 -0
  27. package/v3/@claude-flow/memory/dist/auto-memory-bridge.js +709 -0
  28. package/v3/@claude-flow/memory/dist/auto-memory-bridge.test.d.ts +8 -0
  29. package/v3/@claude-flow/memory/dist/auto-memory-bridge.test.js +754 -0
  30. package/v3/@claude-flow/memory/dist/benchmark.test.d.ts +2 -0
  31. package/v3/@claude-flow/memory/dist/benchmark.test.js +277 -0
  32. package/v3/@claude-flow/memory/dist/cache-manager.d.ts +134 -0
  33. package/v3/@claude-flow/memory/dist/cache-manager.js +407 -0
  34. package/v3/@claude-flow/memory/dist/controller-registry.d.ts +216 -0
  35. package/v3/@claude-flow/memory/dist/controller-registry.js +893 -0
  36. package/v3/@claude-flow/memory/dist/controller-registry.test.d.ts +14 -0
  37. package/v3/@claude-flow/memory/dist/controller-registry.test.js +636 -0
  38. package/v3/@claude-flow/memory/dist/database-provider.d.ts +87 -0
  39. package/v3/@claude-flow/memory/dist/database-provider.js +375 -0
  40. package/v3/@claude-flow/memory/dist/database-provider.test.d.ts +7 -0
  41. package/v3/@claude-flow/memory/dist/database-provider.test.js +285 -0
  42. package/v3/@claude-flow/memory/dist/domain/entities/memory-entry.d.ts +143 -0
  43. package/v3/@claude-flow/memory/dist/domain/entities/memory-entry.js +226 -0
  44. package/v3/@claude-flow/memory/dist/domain/index.d.ts +11 -0
  45. package/v3/@claude-flow/memory/dist/domain/index.js +12 -0
  46. package/v3/@claude-flow/memory/dist/domain/repositories/memory-repository.interface.d.ts +102 -0
  47. package/v3/@claude-flow/memory/dist/domain/repositories/memory-repository.interface.js +11 -0
  48. package/v3/@claude-flow/memory/dist/domain/services/memory-domain-service.d.ts +105 -0
  49. package/v3/@claude-flow/memory/dist/domain/services/memory-domain-service.js +297 -0
  50. package/v3/@claude-flow/memory/dist/hnsw-index.d.ts +111 -0
  51. package/v3/@claude-flow/memory/dist/hnsw-index.js +781 -0
  52. package/v3/@claude-flow/memory/dist/hnsw-lite.d.ts +23 -0
  53. package/v3/@claude-flow/memory/dist/hnsw-lite.js +168 -0
  54. package/v3/@claude-flow/memory/dist/hybrid-backend.d.ts +245 -0
  55. package/v3/@claude-flow/memory/dist/hybrid-backend.js +569 -0
  56. package/v3/@claude-flow/memory/dist/hybrid-backend.test.d.ts +8 -0
  57. package/v3/@claude-flow/memory/dist/hybrid-backend.test.js +320 -0
  58. package/v3/@claude-flow/memory/dist/index.d.ts +207 -0
  59. package/v3/@claude-flow/memory/dist/index.js +361 -0
  60. package/v3/@claude-flow/memory/dist/infrastructure/index.d.ts +17 -0
  61. package/v3/@claude-flow/memory/dist/infrastructure/index.js +16 -0
  62. package/v3/@claude-flow/memory/dist/infrastructure/repositories/hybrid-memory-repository.d.ts +66 -0
  63. package/v3/@claude-flow/memory/dist/infrastructure/repositories/hybrid-memory-repository.js +409 -0
  64. package/v3/@claude-flow/memory/dist/learning-bridge.d.ts +137 -0
  65. package/v3/@claude-flow/memory/dist/learning-bridge.js +335 -0
  66. package/v3/@claude-flow/memory/dist/learning-bridge.test.d.ts +8 -0
  67. package/v3/@claude-flow/memory/dist/learning-bridge.test.js +578 -0
  68. package/v3/@claude-flow/memory/dist/memory-graph.d.ts +100 -0
  69. package/v3/@claude-flow/memory/dist/memory-graph.js +333 -0
  70. package/v3/@claude-flow/memory/dist/memory-graph.test.d.ts +8 -0
  71. package/v3/@claude-flow/memory/dist/memory-graph.test.js +609 -0
  72. package/v3/@claude-flow/memory/dist/migration.d.ts +68 -0
  73. package/v3/@claude-flow/memory/dist/migration.js +513 -0
  74. package/v3/@claude-flow/memory/dist/persistent-sona.d.ts +144 -0
  75. package/v3/@claude-flow/memory/dist/persistent-sona.js +332 -0
  76. package/v3/@claude-flow/memory/dist/query-builder.d.ts +211 -0
  77. package/v3/@claude-flow/memory/dist/query-builder.js +438 -0
  78. package/v3/@claude-flow/memory/dist/rvf-backend.d.ts +51 -0
  79. package/v3/@claude-flow/memory/dist/rvf-backend.js +481 -0
  80. package/v3/@claude-flow/memory/dist/rvf-learning-store.d.ts +139 -0
  81. package/v3/@claude-flow/memory/dist/rvf-learning-store.js +295 -0
  82. package/v3/@claude-flow/memory/dist/rvf-migration.d.ts +45 -0
  83. package/v3/@claude-flow/memory/dist/rvf-migration.js +234 -0
  84. package/v3/@claude-flow/memory/dist/sqlite-backend.d.ts +121 -0
  85. package/v3/@claude-flow/memory/dist/sqlite-backend.js +572 -0
  86. package/v3/@claude-flow/memory/dist/sqljs-backend.d.ts +128 -0
  87. package/v3/@claude-flow/memory/dist/sqljs-backend.js +601 -0
  88. package/v3/@claude-flow/memory/dist/types.d.ts +484 -0
  89. package/v3/@claude-flow/memory/dist/types.js +58 -0
  90. package/v3/@claude-flow/memory/package.json +42 -0
@@ -0,0 +1,320 @@
1
+ /**
2
+ * Tests for HybridBackend (ADR-009)
3
+ *
4
+ * Verifies that the hybrid backend correctly routes queries between
5
+ * SQLite (structured) and AgentDB (semantic) backends.
6
+ */
7
+ import { describe, it, expect, beforeEach, afterEach } from 'vitest';
8
+ import { HybridBackend } from './hybrid-backend.js';
9
+ import { createDefaultEntry } from './types.js';
10
+ describe('HybridBackend - ADR-009', () => {
11
+ let backend;
12
+ // Mock embedding generator for testing
13
+ const mockEmbedding = async (text) => {
14
+ // Simple mock: convert text to numbers
15
+ const arr = new Float32Array(128);
16
+ for (let i = 0; i < Math.min(text.length, 128); i++) {
17
+ arr[i] = text.charCodeAt(i) / 255;
18
+ }
19
+ return arr;
20
+ };
21
+ beforeEach(async () => {
22
+ backend = new HybridBackend({
23
+ sqlite: {
24
+ databasePath: ':memory:', // In-memory for testing
25
+ verbose: false,
26
+ },
27
+ agentdb: {
28
+ vectorDimension: 128,
29
+ },
30
+ embeddingGenerator: mockEmbedding,
31
+ dualWrite: true,
32
+ });
33
+ await backend.initialize();
34
+ });
35
+ afterEach(async () => {
36
+ await backend.shutdown();
37
+ });
38
+ describe('Initialization', () => {
39
+ it('should initialize both backends', async () => {
40
+ const health = await backend.healthCheck();
41
+ expect(health.status).toBe('healthy');
42
+ expect(health.components.storage).toBeDefined();
43
+ expect(health.components.index).toBeDefined();
44
+ expect(health.components.cache).toBeDefined();
45
+ });
46
+ });
47
+ describe('Store Operations', () => {
48
+ it('should store entries in both backends (dual-write)', async () => {
49
+ const entry = createDefaultEntry({
50
+ key: 'test-key',
51
+ content: 'Test content for dual write',
52
+ namespace: 'test',
53
+ });
54
+ await backend.store(entry);
55
+ // Verify in SQLite
56
+ const fromSQLite = await backend.getSQLiteBackend().get(entry.id);
57
+ expect(fromSQLite).toBeDefined();
58
+ expect(fromSQLite?.key).toBe('test-key');
59
+ // Verify in AgentDB
60
+ const fromAgentDB = await backend.getAgentDBBackend().get(entry.id);
61
+ expect(fromAgentDB).toBeDefined();
62
+ expect(fromAgentDB?.key).toBe('test-key');
63
+ });
64
+ it('should handle bulk inserts', async () => {
65
+ const entries = Array.from({ length: 10 }, (_, i) => createDefaultEntry({
66
+ key: `bulk-${i}`,
67
+ content: `Bulk content ${i}`,
68
+ namespace: 'bulk-test',
69
+ }));
70
+ await backend.bulkInsert(entries);
71
+ const count = await backend.count('bulk-test');
72
+ expect(count).toBe(10);
73
+ });
74
+ });
75
+ describe('Exact Match Queries (SQLite)', () => {
76
+ beforeEach(async () => {
77
+ // Insert test data
78
+ await backend.store(createDefaultEntry({
79
+ key: 'user-123',
80
+ content: 'User data for testing',
81
+ namespace: 'users',
82
+ }));
83
+ });
84
+ it('should route exact key queries to SQLite', async () => {
85
+ const result = await backend.getByKey('users', 'user-123');
86
+ expect(result).toBeDefined();
87
+ expect(result?.key).toBe('user-123');
88
+ });
89
+ it('should handle prefix queries via SQLite', async () => {
90
+ await backend.store(createDefaultEntry({
91
+ key: 'user-456',
92
+ content: 'Another user',
93
+ namespace: 'users',
94
+ }));
95
+ const results = await backend.queryStructured({
96
+ namespace: 'users',
97
+ keyPrefix: 'user-',
98
+ limit: 10,
99
+ });
100
+ expect(results.length).toBeGreaterThanOrEqual(2);
101
+ expect(results.every((r) => r.key.startsWith('user-'))).toBe(true);
102
+ });
103
+ });
104
+ describe('Semantic Search (AgentDB)', () => {
105
+ beforeEach(async () => {
106
+ // Insert test data with semantic content
107
+ await backend.store(createDefaultEntry({
108
+ key: 'doc-1',
109
+ content: 'Authentication and authorization patterns',
110
+ namespace: 'docs',
111
+ tags: ['security', 'auth'],
112
+ }));
113
+ await backend.store(createDefaultEntry({
114
+ key: 'doc-2',
115
+ content: 'Database optimization techniques',
116
+ namespace: 'docs',
117
+ tags: ['performance', 'database'],
118
+ }));
119
+ await backend.store(createDefaultEntry({
120
+ key: 'doc-3',
121
+ content: 'Secure authentication methods',
122
+ namespace: 'docs',
123
+ tags: ['security', 'auth'],
124
+ }));
125
+ });
126
+ it('should perform semantic search via AgentDB', async () => {
127
+ const results = await backend.querySemantic({
128
+ content: 'authentication security',
129
+ k: 5,
130
+ threshold: 0.1, // Low threshold for simple mock embeddings
131
+ });
132
+ expect(results.length).toBeGreaterThan(0);
133
+ // Should find docs about authentication
134
+ const hasAuthDoc = results.some((r) => r.content.includes('Authentication'));
135
+ expect(hasAuthDoc).toBe(true);
136
+ });
137
+ it('should support semantic search with filters', async () => {
138
+ const results = await backend.querySemantic({
139
+ content: 'security patterns',
140
+ k: 10,
141
+ filters: {
142
+ type: 'semantic',
143
+ tags: ['security'],
144
+ limit: 10,
145
+ },
146
+ });
147
+ expect(results.every((r) => r.tags.includes('security'))).toBe(true);
148
+ });
149
+ });
150
+ describe('Hybrid Queries', () => {
151
+ beforeEach(async () => {
152
+ // Insert diverse test data
153
+ for (let i = 0; i < 5; i++) {
154
+ await backend.store(createDefaultEntry({
155
+ key: `hybrid-${i}`,
156
+ content: `Content about ${i % 2 === 0 ? 'authentication' : 'database'} topic ${i}`,
157
+ namespace: 'hybrid-test',
158
+ tags: i % 2 === 0 ? ['auth'] : ['db'],
159
+ }));
160
+ }
161
+ });
162
+ it('should combine semantic and structured queries (union)', async () => {
163
+ const results = await backend.queryHybrid({
164
+ semantic: {
165
+ content: 'authentication',
166
+ k: 3,
167
+ },
168
+ structured: {
169
+ namespace: 'hybrid-test',
170
+ keyPrefix: 'hybrid-',
171
+ limit: 5,
172
+ },
173
+ combineStrategy: 'union',
174
+ });
175
+ expect(results.length).toBeGreaterThan(0);
176
+ expect(results.every((r) => r.namespace === 'hybrid-test')).toBe(true);
177
+ });
178
+ it('should support semantic-first strategy', async () => {
179
+ const results = await backend.queryHybrid({
180
+ semantic: {
181
+ content: 'database',
182
+ k: 2,
183
+ },
184
+ structured: {
185
+ namespace: 'hybrid-test',
186
+ limit: 3,
187
+ },
188
+ combineStrategy: 'semantic-first',
189
+ });
190
+ expect(results.length).toBeGreaterThan(0);
191
+ // First results should be from semantic search
192
+ });
193
+ });
194
+ describe('CRUD Operations', () => {
195
+ let testEntry;
196
+ beforeEach(async () => {
197
+ testEntry = createDefaultEntry({
198
+ key: 'crud-test',
199
+ content: 'Original content',
200
+ namespace: 'test',
201
+ });
202
+ await backend.store(testEntry);
203
+ });
204
+ it('should update entries in both backends', async () => {
205
+ const updated = await backend.update(testEntry.id, {
206
+ content: 'Updated content',
207
+ tags: ['updated'],
208
+ });
209
+ expect(updated).toBeDefined();
210
+ expect(updated?.content).toBe('Updated content');
211
+ expect(updated?.tags).toContain('updated');
212
+ // Verify in SQLite
213
+ const fromSQLite = await backend.getSQLiteBackend().get(testEntry.id);
214
+ expect(fromSQLite?.content).toBe('Updated content');
215
+ // Verify in AgentDB
216
+ const fromAgentDB = await backend.getAgentDBBackend().get(testEntry.id);
217
+ expect(fromAgentDB?.content).toBe('Updated content');
218
+ });
219
+ it('should delete entries from both backends', async () => {
220
+ const deleted = await backend.delete(testEntry.id);
221
+ expect(deleted).toBe(true);
222
+ const fromSQLite = await backend.getSQLiteBackend().get(testEntry.id);
223
+ expect(fromSQLite).toBeNull();
224
+ const fromAgentDB = await backend.getAgentDBBackend().get(testEntry.id);
225
+ expect(fromAgentDB).toBeNull();
226
+ });
227
+ });
228
+ describe('Namespace Operations', () => {
229
+ beforeEach(async () => {
230
+ await backend.store(createDefaultEntry({
231
+ key: 'ns1-key',
232
+ content: 'Namespace 1 content',
233
+ namespace: 'ns1',
234
+ }));
235
+ await backend.store(createDefaultEntry({
236
+ key: 'ns2-key',
237
+ content: 'Namespace 2 content',
238
+ namespace: 'ns2',
239
+ }));
240
+ });
241
+ it('should list all namespaces', async () => {
242
+ const namespaces = await backend.listNamespaces();
243
+ expect(namespaces).toContain('ns1');
244
+ expect(namespaces).toContain('ns2');
245
+ });
246
+ it('should count entries per namespace', async () => {
247
+ const ns1Count = await backend.count('ns1');
248
+ const ns2Count = await backend.count('ns2');
249
+ expect(ns1Count).toBe(1);
250
+ expect(ns2Count).toBe(1);
251
+ });
252
+ it('should clear namespace in both backends', async () => {
253
+ const deleted = await backend.clearNamespace('ns1');
254
+ expect(deleted).toBe(1);
255
+ const ns1Count = await backend.count('ns1');
256
+ expect(ns1Count).toBe(0);
257
+ const ns2Count = await backend.count('ns2');
258
+ expect(ns2Count).toBe(1);
259
+ });
260
+ });
261
+ describe('Statistics', () => {
262
+ it('should provide combined statistics', async () => {
263
+ // Add some test data
264
+ for (let i = 0; i < 5; i++) {
265
+ await backend.store(createDefaultEntry({
266
+ key: `stats-${i}`,
267
+ content: `Stats content ${i}`,
268
+ namespace: 'stats',
269
+ }));
270
+ }
271
+ const stats = await backend.getStats();
272
+ expect(stats.totalEntries).toBeGreaterThanOrEqual(5);
273
+ expect(stats.entriesByNamespace['stats']).toBe(5);
274
+ expect(stats.hnswStats).toBeDefined();
275
+ expect(stats.cacheStats).toBeDefined();
276
+ });
277
+ });
278
+ describe('Health Check', () => {
279
+ it('should report healthy status for both backends', async () => {
280
+ const health = await backend.healthCheck();
281
+ expect(health.status).toBe('healthy');
282
+ expect(health.components.storage.status).toBe('healthy');
283
+ expect(health.components.index.status).toBe('healthy');
284
+ expect(health.components.cache.status).toBe('healthy');
285
+ });
286
+ });
287
+ describe('Query Routing', () => {
288
+ it('should auto-route semantic queries to AgentDB', async () => {
289
+ await backend.store(createDefaultEntry({
290
+ key: 'route-test',
291
+ content: 'Routing test content',
292
+ namespace: 'routing',
293
+ }));
294
+ const results = await backend.query({
295
+ type: 'semantic',
296
+ content: 'routing test',
297
+ limit: 5,
298
+ });
299
+ // Verify we got some results
300
+ expect(results).toBeDefined();
301
+ });
302
+ it('should auto-route exact queries to SQLite', async () => {
303
+ await backend.store(createDefaultEntry({
304
+ key: 'exact-test',
305
+ content: 'Exact match test',
306
+ namespace: 'routing',
307
+ }));
308
+ const results = await backend.query({
309
+ type: 'exact',
310
+ key: 'exact-test',
311
+ namespace: 'routing',
312
+ limit: 1,
313
+ });
314
+ // Verify we got the exact result
315
+ expect(results.length).toBeGreaterThan(0);
316
+ expect(results[0].key).toBe('exact-test');
317
+ });
318
+ });
319
+ });
320
+ //# sourceMappingURL=hybrid-backend.test.js.map
@@ -0,0 +1,207 @@
1
+ /**
2
+ * @claude-flow/memory - V3 Unified Memory System
3
+ *
4
+ * Provides a unified memory interface backed by AgentDB with HNSW indexing
5
+ * for 150x-12,500x faster vector search compared to brute-force approaches.
6
+ *
7
+ * @module @claude-flow/memory
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { UnifiedMemoryService, query, QueryTemplates } from '@claude-flow/memory';
12
+ *
13
+ * // Initialize the memory service
14
+ * const memory = new UnifiedMemoryService({
15
+ * dimensions: 1536,
16
+ * cacheEnabled: true,
17
+ * embeddingGenerator: async (text) => embeddings.embed(text),
18
+ * });
19
+ *
20
+ * await memory.initialize();
21
+ *
22
+ * // Store entries
23
+ * await memory.store({
24
+ * key: 'auth-patterns',
25
+ * content: 'OAuth 2.0 implementation patterns for secure authentication',
26
+ * tags: ['auth', 'security', 'patterns'],
27
+ * });
28
+ *
29
+ * // Semantic search
30
+ * const results = await memory.semanticSearch('user authentication best practices', 5);
31
+ *
32
+ * // Query with fluent builder
33
+ * const entries = await memory.query(
34
+ * query()
35
+ * .semantic('security vulnerabilities')
36
+ * .inNamespace('security')
37
+ * .withTags(['critical'])
38
+ * .threshold(0.8)
39
+ * .limit(10)
40
+ * .build()
41
+ * );
42
+ * ```
43
+ */
44
+ export type { MemoryType, AccessLevel, ConsistencyLevel, DistanceMetric, MemoryEntry, MemoryEntryInput, MemoryEntryUpdate, QueryType, MemoryQuery, SearchResult, SearchOptions, HNSWConfig, HNSWStats, QuantizationConfig, IMemoryBackend, BackendStats, HealthCheckResult, ComponentHealth, CacheConfig, CacheStats, CachedEntry, MigrationSource, MigrationConfig, MigrationProgress, MigrationResult, MigrationError, MemoryEventType, MemoryEvent, MemoryEventHandler, SONAMode, LearningPattern, EmbeddingGenerator, } from './types.js';
45
+ export { generateMemoryId, createDefaultEntry, PERFORMANCE_TARGETS, } from './types.js';
46
+ export { AutoMemoryBridge, resolveAutoMemoryDir, findGitRoot } from './auto-memory-bridge.js';
47
+ export type { AutoMemoryBridgeConfig, MemoryInsight, InsightCategory, SyncDirection, SyncMode, PruneStrategy, SyncResult, ImportResult, } from './auto-memory-bridge.js';
48
+ export { LearningBridge } from './learning-bridge.js';
49
+ export type { LearningBridgeConfig, LearningStats, ConsolidateResult, PatternMatch, } from './learning-bridge.js';
50
+ export { RvfLearningStore } from './rvf-learning-store.js';
51
+ export type { RvfLearningStoreConfig, PatternRecord, LoraRecord, EwcRecord, TrajectoryRecord, } from './rvf-learning-store.js';
52
+ export { PersistentSonaCoordinator } from './persistent-sona.js';
53
+ export type { PersistentSonaConfig } from './persistent-sona.js';
54
+ export { RvfMigrator } from './rvf-migration.js';
55
+ export type { RvfMigrationOptions, RvfMigrationResult } from './rvf-migration.js';
56
+ export { MemoryGraph } from './memory-graph.js';
57
+ export type { MemoryGraphConfig, GraphNode, GraphEdge, GraphStats, RankedResult, EdgeType, } from './memory-graph.js';
58
+ export { resolveAgentMemoryDir, createAgentBridge, transferKnowledge, listAgentScopes, } from './agent-memory-scope.js';
59
+ export type { AgentMemoryScope, AgentScopedConfig, TransferOptions, TransferResult, } from './agent-memory-scope.js';
60
+ export { ControllerRegistry, INIT_LEVELS } from './controller-registry.js';
61
+ export type { AgentDBControllerName, CLIControllerName, ControllerName, InitLevel, ControllerHealth, RegistryHealthReport, RuntimeConfig, } from './controller-registry.js';
62
+ export { AgentDBAdapter } from './agentdb-adapter.js';
63
+ export type { AgentDBAdapterConfig } from './agentdb-adapter.js';
64
+ export { AgentDBBackend } from './agentdb-backend.js';
65
+ export type { AgentDBBackendConfig } from './agentdb-backend.js';
66
+ export type { SQLiteBackendConfig } from './sqlite-backend.js';
67
+ export { SqlJsBackend } from './sqljs-backend.js';
68
+ export type { SqlJsBackendConfig } from './sqljs-backend.js';
69
+ export { HybridBackend } from './hybrid-backend.js';
70
+ export type { HybridBackendConfig, StructuredQuery, SemanticQuery, HybridQuery, } from './hybrid-backend.js';
71
+ export { RvfBackend } from './rvf-backend.js';
72
+ export type { RvfBackendConfig } from './rvf-backend.js';
73
+ export { HnswLite, cosineSimilarity } from './hnsw-lite.js';
74
+ export type { HnswSearchResult } from './hnsw-lite.js';
75
+ export { HNSWIndex } from './hnsw-index.js';
76
+ export { CacheManager, TieredCacheManager } from './cache-manager.js';
77
+ export { QueryBuilder, query, QueryTemplates } from './query-builder.js';
78
+ export type { SortDirection, SortField } from './query-builder.js';
79
+ export { MemoryMigrator, createMigrator, migrateMultipleSources } from './migration.js';
80
+ export { createDatabase, getPlatformInfo, getAvailableProviders } from './database-provider.js';
81
+ export type { DatabaseProvider, DatabaseOptions } from './database-provider.js';
82
+ import { EventEmitter } from 'node:events';
83
+ import { IMemoryBackend, MemoryEntry, MemoryEntryInput, MemoryEntryUpdate, MemoryQuery, SearchResult, SearchOptions, BackendStats, HealthCheckResult, EmbeddingGenerator, MigrationSource, MigrationConfig, MigrationResult } from './types.js';
84
+ import { AgentDBAdapter, AgentDBAdapterConfig } from './agentdb-adapter.js';
85
+ /**
86
+ * Configuration for UnifiedMemoryService
87
+ */
88
+ export interface UnifiedMemoryServiceConfig extends Partial<AgentDBAdapterConfig> {
89
+ /** Enable automatic embedding generation */
90
+ autoEmbed?: boolean;
91
+ /** Default embedding dimensions */
92
+ dimensions?: number;
93
+ /** Embedding generator function */
94
+ embeddingGenerator?: EmbeddingGenerator;
95
+ }
96
+ /**
97
+ * Unified Memory Service
98
+ *
99
+ * High-level interface for the V3 memory system that provides:
100
+ * - Simple API for common operations
101
+ * - Automatic embedding generation
102
+ * - Cross-agent memory sharing
103
+ * - SONA integration for learning
104
+ * - Event-driven notifications
105
+ * - Performance monitoring
106
+ */
107
+ export declare class UnifiedMemoryService extends EventEmitter implements IMemoryBackend {
108
+ private adapter;
109
+ private config;
110
+ private initialized;
111
+ constructor(config?: UnifiedMemoryServiceConfig);
112
+ initialize(): Promise<void>;
113
+ shutdown(): Promise<void>;
114
+ store(entry: MemoryEntry): Promise<void>;
115
+ get(id: string): Promise<MemoryEntry | null>;
116
+ getByKey(namespace: string, key: string): Promise<MemoryEntry | null>;
117
+ update(id: string, update: MemoryEntryUpdate): Promise<MemoryEntry | null>;
118
+ delete(id: string): Promise<boolean>;
119
+ query(query: MemoryQuery): Promise<MemoryEntry[]>;
120
+ search(embedding: Float32Array, options: SearchOptions): Promise<SearchResult[]>;
121
+ bulkInsert(entries: MemoryEntry[]): Promise<void>;
122
+ bulkDelete(ids: string[]): Promise<number>;
123
+ count(namespace?: string): Promise<number>;
124
+ listNamespaces(): Promise<string[]>;
125
+ clearNamespace(namespace: string): Promise<number>;
126
+ getStats(): Promise<BackendStats>;
127
+ healthCheck(): Promise<HealthCheckResult>;
128
+ /**
129
+ * Store an entry from simple input
130
+ */
131
+ storeEntry(input: MemoryEntryInput): Promise<MemoryEntry>;
132
+ /**
133
+ * Semantic search by content string
134
+ */
135
+ semanticSearch(content: string, k?: number, threshold?: number): Promise<SearchResult[]>;
136
+ /**
137
+ * Find similar entries to a given entry
138
+ */
139
+ findSimilar(id: string, k?: number): Promise<SearchResult[]>;
140
+ /**
141
+ * Get or create an entry
142
+ */
143
+ getOrCreate(namespace: string, key: string, creator: () => MemoryEntryInput | Promise<MemoryEntryInput>): Promise<MemoryEntry>;
144
+ /**
145
+ * Append content to an existing entry
146
+ */
147
+ appendContent(id: string, content: string): Promise<MemoryEntry | null>;
148
+ /**
149
+ * Add tags to an existing entry
150
+ */
151
+ addTags(id: string, tags: string[]): Promise<MemoryEntry | null>;
152
+ /**
153
+ * Remove tags from an existing entry
154
+ */
155
+ removeTags(id: string, tags: string[]): Promise<MemoryEntry | null>;
156
+ /**
157
+ * Migrate from a legacy memory source
158
+ */
159
+ migrateFrom(source: MigrationSource, sourcePath: string, options?: Partial<MigrationConfig>): Promise<MigrationResult>;
160
+ /**
161
+ * Share an entry with another agent
162
+ */
163
+ shareWith(id: string, agentId: string): Promise<MemoryEntry | null>;
164
+ /**
165
+ * Get entries shared with a specific agent
166
+ */
167
+ getSharedWith(agentId: string): Promise<MemoryEntry[]>;
168
+ /**
169
+ * Get the underlying adapter for advanced operations
170
+ */
171
+ getAdapter(): AgentDBAdapter;
172
+ /**
173
+ * Check if the service is initialized
174
+ */
175
+ isInitialized(): boolean;
176
+ }
177
+ /**
178
+ * Create a simple in-memory service (for testing)
179
+ */
180
+ export declare function createInMemoryService(): UnifiedMemoryService;
181
+ /**
182
+ * Create a persistent memory service
183
+ */
184
+ export declare function createPersistentService(path: string): UnifiedMemoryService;
185
+ /**
186
+ * Create a memory service with embedding support
187
+ */
188
+ export declare function createEmbeddingService(embeddingGenerator: EmbeddingGenerator, dimensions?: number): UnifiedMemoryService;
189
+ /**
190
+ * Create a hybrid memory service (SQLite + AgentDB)
191
+ * This is the DEFAULT recommended configuration per ADR-009
192
+ *
193
+ * @example
194
+ * ```typescript
195
+ * const memory = createHybridService('./data/memory.db', embeddingFn);
196
+ * await memory.initialize();
197
+ *
198
+ * // Structured queries go to SQLite
199
+ * const user = await memory.getByKey('users', 'john@example.com');
200
+ *
201
+ * // Semantic queries go to AgentDB
202
+ * const similar = await memory.semanticSearch('authentication patterns', 10);
203
+ * ```
204
+ */
205
+ export declare function createHybridService(databasePath: string, embeddingGenerator: EmbeddingGenerator, dimensions?: number): UnifiedMemoryService;
206
+ export default UnifiedMemoryService;
207
+ //# sourceMappingURL=index.d.ts.map