agentic-flow 2.0.1-alpha.17 → 2.0.1-alpha.19
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/CHANGELOG.md +76 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/intelligence/EmbeddingCache.d.ts +105 -0
- package/dist/intelligence/EmbeddingCache.d.ts.map +1 -0
- package/dist/intelligence/EmbeddingCache.js +253 -0
- package/dist/intelligence/EmbeddingCache.js.map +1 -0
- package/dist/intelligence/EmbeddingService.d.ts +213 -1
- package/dist/intelligence/EmbeddingService.d.ts.map +1 -1
- package/dist/intelligence/EmbeddingService.js +965 -7
- package/dist/intelligence/EmbeddingService.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EmbeddingCache - Persistent SQLite cache for embeddings
|
|
3
|
+
*
|
|
4
|
+
* Makes ONNX embeddings practical by caching across sessions:
|
|
5
|
+
* - First embed: ~400ms (ONNX inference)
|
|
6
|
+
* - Cached embed: ~0.1ms (SQLite lookup)
|
|
7
|
+
*
|
|
8
|
+
* Storage: ~/.agentic-flow/embedding-cache.db
|
|
9
|
+
*/
|
|
10
|
+
export interface CacheStats {
|
|
11
|
+
totalEntries: number;
|
|
12
|
+
hits: number;
|
|
13
|
+
misses: number;
|
|
14
|
+
hitRate: number;
|
|
15
|
+
dbSizeBytes: number;
|
|
16
|
+
oldestEntry: number;
|
|
17
|
+
newestEntry: number;
|
|
18
|
+
}
|
|
19
|
+
export interface CacheConfig {
|
|
20
|
+
maxEntries?: number;
|
|
21
|
+
maxAgeDays?: number;
|
|
22
|
+
dbPath?: string;
|
|
23
|
+
dimension?: number;
|
|
24
|
+
}
|
|
25
|
+
export declare class EmbeddingCache {
|
|
26
|
+
private db;
|
|
27
|
+
private config;
|
|
28
|
+
private hits;
|
|
29
|
+
private misses;
|
|
30
|
+
private stmtGet;
|
|
31
|
+
private stmtInsert;
|
|
32
|
+
private stmtUpdateHits;
|
|
33
|
+
private stmtCount;
|
|
34
|
+
private stmtEvictOld;
|
|
35
|
+
private stmtEvictLRU;
|
|
36
|
+
constructor(config?: CacheConfig);
|
|
37
|
+
private initSchema;
|
|
38
|
+
private prepareStatements;
|
|
39
|
+
/**
|
|
40
|
+
* Generate hash key for text + model combination
|
|
41
|
+
*/
|
|
42
|
+
private hashKey;
|
|
43
|
+
/**
|
|
44
|
+
* Get embedding from cache
|
|
45
|
+
* Returns null if not found
|
|
46
|
+
*/
|
|
47
|
+
get(text: string, model?: string): Float32Array | null;
|
|
48
|
+
/**
|
|
49
|
+
* Store embedding in cache
|
|
50
|
+
*/
|
|
51
|
+
set(text: string, embedding: Float32Array, model?: string): void;
|
|
52
|
+
/**
|
|
53
|
+
* Check if text is cached
|
|
54
|
+
*/
|
|
55
|
+
has(text: string, model?: string): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Get multiple embeddings at once
|
|
58
|
+
* Returns map of text -> embedding (only cached ones)
|
|
59
|
+
*/
|
|
60
|
+
getMany(texts: string[], model?: string): Map<string, Float32Array>;
|
|
61
|
+
/**
|
|
62
|
+
* Store multiple embeddings at once
|
|
63
|
+
*/
|
|
64
|
+
setMany(entries: Array<{
|
|
65
|
+
text: string;
|
|
66
|
+
embedding: Float32Array;
|
|
67
|
+
}>, model?: string): void;
|
|
68
|
+
/**
|
|
69
|
+
* Evict old or LRU entries if over limit
|
|
70
|
+
*/
|
|
71
|
+
private maybeEvict;
|
|
72
|
+
/**
|
|
73
|
+
* Cleanup entries older than maxAgeDays
|
|
74
|
+
*/
|
|
75
|
+
private cleanupOldEntries;
|
|
76
|
+
/**
|
|
77
|
+
* Get cache statistics
|
|
78
|
+
*/
|
|
79
|
+
getStats(): CacheStats;
|
|
80
|
+
/**
|
|
81
|
+
* Clear all cached embeddings
|
|
82
|
+
*/
|
|
83
|
+
clear(): void;
|
|
84
|
+
/**
|
|
85
|
+
* Clear embeddings for a specific model
|
|
86
|
+
*/
|
|
87
|
+
clearModel(model: string): void;
|
|
88
|
+
/**
|
|
89
|
+
* Vacuum database to reclaim space
|
|
90
|
+
*/
|
|
91
|
+
vacuum(): void;
|
|
92
|
+
/**
|
|
93
|
+
* Close database connection
|
|
94
|
+
*/
|
|
95
|
+
close(): void;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Get the singleton embedding cache
|
|
99
|
+
*/
|
|
100
|
+
export declare function getEmbeddingCache(config?: CacheConfig): EmbeddingCache;
|
|
101
|
+
/**
|
|
102
|
+
* Reset the cache singleton (for testing)
|
|
103
|
+
*/
|
|
104
|
+
export declare function resetEmbeddingCache(): void;
|
|
105
|
+
//# sourceMappingURL=EmbeddingCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmbeddingCache.d.ts","sourceRoot":"","sources":["../../src/intelligence/EmbeddingCache.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAQH,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAUD,qBAAa,cAAc;IACzB,OAAO,CAAC,EAAE,CAAoB;IAC9B,OAAO,CAAC,MAAM,CAAwB;IACtC,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,MAAM,CAAa;IAG3B,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,cAAc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I,CAK1C"}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EmbeddingCache - Persistent SQLite cache for embeddings
|
|
3
|
+
*
|
|
4
|
+
* Makes ONNX embeddings practical by caching across sessions:
|
|
5
|
+
* - First embed: ~400ms (ONNX inference)
|
|
6
|
+
* - Cached embed: ~0.1ms (SQLite lookup)
|
|
7
|
+
*
|
|
8
|
+
* Storage: ~/.agentic-flow/embedding-cache.db
|
|
9
|
+
*/
|
|
10
|
+
import Database from 'better-sqlite3';
|
|
11
|
+
import { existsSync, mkdirSync } from 'fs';
|
|
12
|
+
import { join } from 'path';
|
|
13
|
+
import { homedir } from 'os';
|
|
14
|
+
import { createHash } from 'crypto';
|
|
15
|
+
// Default config
|
|
16
|
+
const DEFAULT_CONFIG = {
|
|
17
|
+
maxEntries: 10000,
|
|
18
|
+
maxAgeDays: 30,
|
|
19
|
+
dbPath: join(homedir(), '.agentic-flow', 'embedding-cache.db'),
|
|
20
|
+
dimension: 384,
|
|
21
|
+
};
|
|
22
|
+
export class EmbeddingCache {
|
|
23
|
+
db;
|
|
24
|
+
config;
|
|
25
|
+
hits = 0;
|
|
26
|
+
misses = 0;
|
|
27
|
+
// Prepared statements for performance
|
|
28
|
+
stmtGet;
|
|
29
|
+
stmtInsert;
|
|
30
|
+
stmtUpdateHits;
|
|
31
|
+
stmtCount;
|
|
32
|
+
stmtEvictOld;
|
|
33
|
+
stmtEvictLRU;
|
|
34
|
+
constructor(config = {}) {
|
|
35
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
36
|
+
// Ensure directory exists
|
|
37
|
+
const dir = join(homedir(), '.agentic-flow');
|
|
38
|
+
if (!existsSync(dir)) {
|
|
39
|
+
mkdirSync(dir, { recursive: true });
|
|
40
|
+
}
|
|
41
|
+
// Open database with WAL mode for better concurrency
|
|
42
|
+
this.db = new Database(this.config.dbPath);
|
|
43
|
+
this.db.pragma('journal_mode = WAL');
|
|
44
|
+
this.db.pragma('synchronous = NORMAL');
|
|
45
|
+
this.db.pragma('cache_size = 10000');
|
|
46
|
+
this.initSchema();
|
|
47
|
+
this.prepareStatements();
|
|
48
|
+
this.cleanupOldEntries();
|
|
49
|
+
}
|
|
50
|
+
initSchema() {
|
|
51
|
+
this.db.exec(`
|
|
52
|
+
CREATE TABLE IF NOT EXISTS embeddings (
|
|
53
|
+
hash TEXT PRIMARY KEY,
|
|
54
|
+
text TEXT NOT NULL,
|
|
55
|
+
embedding BLOB NOT NULL,
|
|
56
|
+
dimension INTEGER NOT NULL,
|
|
57
|
+
model TEXT NOT NULL,
|
|
58
|
+
hits INTEGER DEFAULT 1,
|
|
59
|
+
created_at INTEGER NOT NULL,
|
|
60
|
+
last_accessed INTEGER NOT NULL
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
CREATE INDEX IF NOT EXISTS idx_last_accessed ON embeddings(last_accessed);
|
|
64
|
+
CREATE INDEX IF NOT EXISTS idx_created_at ON embeddings(created_at);
|
|
65
|
+
CREATE INDEX IF NOT EXISTS idx_model ON embeddings(model);
|
|
66
|
+
`);
|
|
67
|
+
}
|
|
68
|
+
prepareStatements() {
|
|
69
|
+
this.stmtGet = this.db.prepare(`
|
|
70
|
+
SELECT embedding, dimension FROM embeddings WHERE hash = ?
|
|
71
|
+
`);
|
|
72
|
+
this.stmtInsert = this.db.prepare(`
|
|
73
|
+
INSERT OR REPLACE INTO embeddings (hash, text, embedding, dimension, model, hits, created_at, last_accessed)
|
|
74
|
+
VALUES (?, ?, ?, ?, ?, 1, ?, ?)
|
|
75
|
+
`);
|
|
76
|
+
this.stmtUpdateHits = this.db.prepare(`
|
|
77
|
+
UPDATE embeddings SET hits = hits + 1, last_accessed = ? WHERE hash = ?
|
|
78
|
+
`);
|
|
79
|
+
this.stmtCount = this.db.prepare(`SELECT COUNT(*) as count FROM embeddings`);
|
|
80
|
+
this.stmtEvictOld = this.db.prepare(`
|
|
81
|
+
DELETE FROM embeddings WHERE created_at < ?
|
|
82
|
+
`);
|
|
83
|
+
this.stmtEvictLRU = this.db.prepare(`
|
|
84
|
+
DELETE FROM embeddings WHERE hash IN (
|
|
85
|
+
SELECT hash FROM embeddings ORDER BY last_accessed ASC LIMIT ?
|
|
86
|
+
)
|
|
87
|
+
`);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Generate hash key for text + model combination
|
|
91
|
+
*/
|
|
92
|
+
hashKey(text, model = 'default') {
|
|
93
|
+
return createHash('sha256').update(`${model}:${text}`).digest('hex').slice(0, 32);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Get embedding from cache
|
|
97
|
+
* Returns null if not found
|
|
98
|
+
*/
|
|
99
|
+
get(text, model = 'default') {
|
|
100
|
+
const hash = this.hashKey(text, model);
|
|
101
|
+
const row = this.stmtGet.get(hash);
|
|
102
|
+
if (row) {
|
|
103
|
+
this.hits++;
|
|
104
|
+
// Update access time and hit count
|
|
105
|
+
this.stmtUpdateHits.run(Date.now(), hash);
|
|
106
|
+
// Convert Buffer back to Float32Array
|
|
107
|
+
return new Float32Array(row.embedding.buffer, row.embedding.byteOffset, row.dimension);
|
|
108
|
+
}
|
|
109
|
+
this.misses++;
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Store embedding in cache
|
|
114
|
+
*/
|
|
115
|
+
set(text, embedding, model = 'default') {
|
|
116
|
+
const hash = this.hashKey(text, model);
|
|
117
|
+
const now = Date.now();
|
|
118
|
+
// Convert Float32Array to Buffer
|
|
119
|
+
const buffer = Buffer.from(embedding.buffer, embedding.byteOffset, embedding.byteLength);
|
|
120
|
+
this.stmtInsert.run(hash, text, buffer, embedding.length, model, now, now);
|
|
121
|
+
// Check if we need to evict
|
|
122
|
+
this.maybeEvict();
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Check if text is cached
|
|
126
|
+
*/
|
|
127
|
+
has(text, model = 'default') {
|
|
128
|
+
const hash = this.hashKey(text, model);
|
|
129
|
+
const row = this.stmtGet.get(hash);
|
|
130
|
+
return row !== undefined;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Get multiple embeddings at once
|
|
134
|
+
* Returns map of text -> embedding (only cached ones)
|
|
135
|
+
*/
|
|
136
|
+
getMany(texts, model = 'default') {
|
|
137
|
+
const result = new Map();
|
|
138
|
+
for (const text of texts) {
|
|
139
|
+
const embedding = this.get(text, model);
|
|
140
|
+
if (embedding) {
|
|
141
|
+
result.set(text, embedding);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Store multiple embeddings at once
|
|
148
|
+
*/
|
|
149
|
+
setMany(entries, model = 'default') {
|
|
150
|
+
const insertMany = this.db.transaction((items) => {
|
|
151
|
+
const now = Date.now();
|
|
152
|
+
for (const { text, embedding } of items) {
|
|
153
|
+
const hash = this.hashKey(text, model);
|
|
154
|
+
const buffer = Buffer.from(embedding.buffer, embedding.byteOffset, embedding.byteLength);
|
|
155
|
+
this.stmtInsert.run(hash, text, buffer, embedding.length, model, now, now);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
insertMany(entries);
|
|
159
|
+
this.maybeEvict();
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Evict old or LRU entries if over limit
|
|
163
|
+
*/
|
|
164
|
+
maybeEvict() {
|
|
165
|
+
const count = this.stmtCount.get().count;
|
|
166
|
+
if (count > this.config.maxEntries) {
|
|
167
|
+
// Evict 10% of entries (LRU)
|
|
168
|
+
const toEvict = Math.ceil(this.config.maxEntries * 0.1);
|
|
169
|
+
this.stmtEvictLRU.run(toEvict);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Cleanup entries older than maxAgeDays
|
|
174
|
+
*/
|
|
175
|
+
cleanupOldEntries() {
|
|
176
|
+
const cutoff = Date.now() - (this.config.maxAgeDays * 24 * 60 * 60 * 1000);
|
|
177
|
+
this.stmtEvictOld.run(cutoff);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Get cache statistics
|
|
181
|
+
*/
|
|
182
|
+
getStats() {
|
|
183
|
+
const count = this.stmtCount.get().count;
|
|
184
|
+
const oldest = this.db.prepare(`SELECT MIN(created_at) as oldest FROM embeddings`).get();
|
|
185
|
+
const newest = this.db.prepare(`SELECT MAX(created_at) as newest FROM embeddings`).get();
|
|
186
|
+
// Get database file size
|
|
187
|
+
let dbSizeBytes = 0;
|
|
188
|
+
try {
|
|
189
|
+
const fs = require('fs');
|
|
190
|
+
const stats = fs.statSync(this.config.dbPath);
|
|
191
|
+
dbSizeBytes = stats.size;
|
|
192
|
+
}
|
|
193
|
+
catch {
|
|
194
|
+
// Ignore
|
|
195
|
+
}
|
|
196
|
+
return {
|
|
197
|
+
totalEntries: count,
|
|
198
|
+
hits: this.hits,
|
|
199
|
+
misses: this.misses,
|
|
200
|
+
hitRate: this.hits + this.misses > 0 ? this.hits / (this.hits + this.misses) : 0,
|
|
201
|
+
dbSizeBytes,
|
|
202
|
+
oldestEntry: oldest.oldest || 0,
|
|
203
|
+
newestEntry: newest.newest || 0,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Clear all cached embeddings
|
|
208
|
+
*/
|
|
209
|
+
clear() {
|
|
210
|
+
this.db.exec('DELETE FROM embeddings');
|
|
211
|
+
this.hits = 0;
|
|
212
|
+
this.misses = 0;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Clear embeddings for a specific model
|
|
216
|
+
*/
|
|
217
|
+
clearModel(model) {
|
|
218
|
+
this.db.prepare('DELETE FROM embeddings WHERE model = ?').run(model);
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Vacuum database to reclaim space
|
|
222
|
+
*/
|
|
223
|
+
vacuum() {
|
|
224
|
+
this.db.exec('VACUUM');
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Close database connection
|
|
228
|
+
*/
|
|
229
|
+
close() {
|
|
230
|
+
this.db.close();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
// Singleton instance
|
|
234
|
+
let cacheInstance = null;
|
|
235
|
+
/**
|
|
236
|
+
* Get the singleton embedding cache
|
|
237
|
+
*/
|
|
238
|
+
export function getEmbeddingCache(config) {
|
|
239
|
+
if (!cacheInstance) {
|
|
240
|
+
cacheInstance = new EmbeddingCache(config);
|
|
241
|
+
}
|
|
242
|
+
return cacheInstance;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Reset the cache singleton (for testing)
|
|
246
|
+
*/
|
|
247
|
+
export function resetEmbeddingCache() {
|
|
248
|
+
if (cacheInstance) {
|
|
249
|
+
cacheInstance.close();
|
|
250
|
+
cacheInstance = null;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
//# sourceMappingURL=EmbeddingCache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmbeddingCache.js","sourceRoot":"","sources":["../../src/intelligence/EmbeddingCache.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAmBpC,iBAAiB;AACjB,MAAM,cAAc,GAA0B;IAC5C,UAAU,EAAE,KAAK;IACjB,UAAU,EAAE,EAAE;IACd,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,eAAe,EAAE,oBAAoB,CAAC;IAC9D,SAAS,EAAE,GAAG;CACf,CAAC;AAEF,MAAM,OAAO,cAAc;IACjB,EAAE,CAAoB;IACtB,MAAM,CAAwB;IAC9B,IAAI,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d,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAClB,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,KAAa;QACtB,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,wCAAwC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACvE,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;CACF;AAED,qBAAqB;AACrB,IAAI,aAAa,GAA0B,IAAI,CAAC;AAEhD;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAoB;IACpD,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,aAAa,GAAG,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB;IACjC,IAAI,aAAa,EAAE,CAAC;QAClB,aAAa,CAAC,KAAK,EAAE,CAAC;QACtB,aAAa,GAAG,IAAI,CAAC;IACvB,CAAC;AACH,CAAC","sourcesContent":["/**\n * EmbeddingCache - Persistent SQLite cache for embeddings\n *\n * Makes ONNX embeddings practical by caching across sessions:\n * - First embed: ~400ms (ONNX inference)\n * - Cached embed: ~0.1ms (SQLite lookup)\n *\n * Storage: ~/.agentic-flow/embedding-cache.db\n */\n\nimport Database from 'better-sqlite3';\nimport { existsSync, mkdirSync } from 'fs';\nimport { join } from 'path';\nimport { homedir } from 'os';\nimport { createHash } from 'crypto';\n\nexport interface CacheStats {\n totalEntries: number;\n hits: number;\n misses: number;\n hitRate: number;\n dbSizeBytes: number;\n oldestEntry: number;\n newestEntry: number;\n}\n\nexport interface CacheConfig {\n maxEntries?: number; // Max cache entries (default: 10000)\n maxAgeDays?: number; // Max age before eviction (default: 30)\n dbPath?: string; // Custom database path\n dimension?: number; // Embedding dimension (default: 384)\n}\n\n// Default config\nconst DEFAULT_CONFIG: Required<CacheConfig> = {\n maxEntries: 10000,\n maxAgeDays: 30,\n dbPath: join(homedir(), '.agentic-flow', 'embedding-cache.db'),\n dimension: 384,\n};\n\nexport class EmbeddingCache {\n private db: Database.Database;\n private config: Required<CacheConfig>;\n private hits: number = 0;\n private misses: number = 0;\n\n // Prepared statements for performance\n private stmtGet!: Database.Statement;\n private stmtInsert!: Database.Statement;\n private stmtUpdateHits!: Database.Statement;\n private stmtCount!: Database.Statement;\n private stmtEvictOld!: Database.Statement;\n private stmtEvictLRU!: Database.Statement;\n\n constructor(config: CacheConfig = {}) {\n this.config = { ...DEFAULT_CONFIG, ...config };\n\n // Ensure directory exists\n const dir = join(homedir(), '.agentic-flow');\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true });\n }\n\n // Open database with WAL mode for better concurrency\n this.db = new Database(this.config.dbPath);\n this.db.pragma('journal_mode = WAL');\n this.db.pragma('synchronous = NORMAL');\n this.db.pragma('cache_size = 10000');\n\n this.initSchema();\n this.prepareStatements();\n this.cleanupOldEntries();\n }\n\n private initSchema(): void {\n this.db.exec(`\n CREATE TABLE IF NOT EXISTS embeddings (\n hash TEXT PRIMARY KEY,\n text TEXT NOT NULL,\n embedding BLOB NOT NULL,\n dimension INTEGER NOT NULL,\n model TEXT NOT NULL,\n hits INTEGER DEFAULT 1,\n created_at INTEGER NOT NULL,\n last_accessed INTEGER NOT NULL\n );\n\n CREATE INDEX IF NOT EXISTS idx_last_accessed ON embeddings(last_accessed);\n CREATE INDEX IF NOT EXISTS idx_created_at ON embeddings(created_at);\n CREATE INDEX IF NOT EXISTS idx_model ON embeddings(model);\n `);\n }\n\n private prepareStatements(): void {\n this.stmtGet = this.db.prepare(`\n SELECT embedding, dimension FROM embeddings WHERE hash = ?\n `);\n\n this.stmtInsert = this.db.prepare(`\n INSERT OR REPLACE INTO embeddings (hash, text, embedding, dimension, model, hits, created_at, last_accessed)\n VALUES (?, ?, ?, ?, ?, 1, ?, ?)\n `);\n\n this.stmtUpdateHits = this.db.prepare(`\n UPDATE embeddings SET hits = hits + 1, last_accessed = ? WHERE hash = ?\n `);\n\n this.stmtCount = this.db.prepare(`SELECT COUNT(*) as count FROM embeddings`);\n\n this.stmtEvictOld = this.db.prepare(`\n DELETE FROM embeddings WHERE created_at < ?\n `);\n\n this.stmtEvictLRU = this.db.prepare(`\n DELETE FROM embeddings WHERE hash IN (\n SELECT hash FROM embeddings ORDER BY last_accessed ASC LIMIT ?\n )\n `);\n }\n\n /**\n * Generate hash key for text + model combination\n */\n private hashKey(text: string, model: string = 'default'): string {\n return createHash('sha256').update(`${model}:${text}`).digest('hex').slice(0, 32);\n }\n\n /**\n * Get embedding from cache\n * Returns null if not found\n */\n get(text: string, model: string = 'default'): Float32Array | null {\n const hash = this.hashKey(text, model);\n const row = this.stmtGet.get(hash) as { embedding: Buffer; dimension: number } | undefined;\n\n if (row) {\n this.hits++;\n // Update access time and hit count\n this.stmtUpdateHits.run(Date.now(), hash);\n // Convert Buffer back to Float32Array\n return new Float32Array(row.embedding.buffer, row.embedding.byteOffset, row.dimension);\n }\n\n this.misses++;\n return null;\n }\n\n /**\n * Store embedding in cache\n */\n set(text: string, embedding: Float32Array, model: string = 'default'): void {\n const hash = this.hashKey(text, model);\n const now = Date.now();\n\n // Convert Float32Array to Buffer\n const buffer = Buffer.from(embedding.buffer, embedding.byteOffset, embedding.byteLength);\n\n this.stmtInsert.run(hash, text, buffer, embedding.length, model, now, now);\n\n // Check if we need to evict\n this.maybeEvict();\n }\n\n /**\n * Check if text is cached\n */\n has(text: string, model: string = 'default'): boolean {\n const hash = this.hashKey(text, model);\n const row = this.stmtGet.get(hash);\n return row !== undefined;\n }\n\n /**\n * Get multiple embeddings at once\n * Returns map of text -> embedding (only cached ones)\n */\n getMany(texts: string[], model: string = 'default'): Map<string, Float32Array> {\n const result = new Map<string, Float32Array>();\n\n for (const text of texts) {\n const embedding = this.get(text, model);\n if (embedding) {\n result.set(text, embedding);\n }\n }\n\n return result;\n }\n\n /**\n * Store multiple embeddings at once\n */\n setMany(entries: Array<{ text: string; embedding: Float32Array }>, model: string = 'default'): void {\n const insertMany = this.db.transaction((items: typeof entries) => {\n const now = Date.now();\n for (const { text, embedding } of items) {\n const hash = this.hashKey(text, model);\n const buffer = Buffer.from(embedding.buffer, embedding.byteOffset, embedding.byteLength);\n this.stmtInsert.run(hash, text, buffer, embedding.length, model, now, now);\n }\n });\n\n insertMany(entries);\n this.maybeEvict();\n }\n\n /**\n * Evict old or LRU entries if over limit\n */\n private maybeEvict(): void {\n const count = (this.stmtCount.get() as { count: number }).count;\n\n if (count > this.config.maxEntries) {\n // Evict 10% of entries (LRU)\n const toEvict = Math.ceil(this.config.maxEntries * 0.1);\n this.stmtEvictLRU.run(toEvict);\n }\n }\n\n /**\n * Cleanup entries older than maxAgeDays\n */\n private cleanupOldEntries(): void {\n const cutoff = Date.now() - (this.config.maxAgeDays * 24 * 60 * 60 * 1000);\n this.stmtEvictOld.run(cutoff);\n }\n\n /**\n * Get cache statistics\n */\n getStats(): CacheStats {\n const count = (this.stmtCount.get() as { count: number }).count;\n\n const oldest = this.db.prepare(`SELECT MIN(created_at) as oldest FROM embeddings`).get() as { oldest: number | null };\n const newest = this.db.prepare(`SELECT MAX(created_at) as newest FROM embeddings`).get() as { newest: number | null };\n\n // Get database file size\n let dbSizeBytes = 0;\n try {\n const fs = require('fs');\n const stats = fs.statSync(this.config.dbPath);\n dbSizeBytes = stats.size;\n } catch {\n // Ignore\n }\n\n return {\n totalEntries: count,\n hits: this.hits,\n misses: this.misses,\n hitRate: this.hits + this.misses > 0 ? this.hits / (this.hits + this.misses) : 0,\n dbSizeBytes,\n oldestEntry: oldest.oldest || 0,\n newestEntry: newest.newest || 0,\n };\n }\n\n /**\n * Clear all cached embeddings\n */\n clear(): void {\n this.db.exec('DELETE FROM embeddings');\n this.hits = 0;\n this.misses = 0;\n }\n\n /**\n * Clear embeddings for a specific model\n */\n clearModel(model: string): void {\n this.db.prepare('DELETE FROM embeddings WHERE model = ?').run(model);\n }\n\n /**\n * Vacuum database to reclaim space\n */\n vacuum(): void {\n this.db.exec('VACUUM');\n }\n\n /**\n * Close database connection\n */\n close(): void {\n this.db.close();\n }\n}\n\n// Singleton instance\nlet cacheInstance: EmbeddingCache | null = null;\n\n/**\n * Get the singleton embedding cache\n */\nexport function getEmbeddingCache(config?: CacheConfig): EmbeddingCache {\n if (!cacheInstance) {\n cacheInstance = new EmbeddingCache(config);\n }\n return cacheInstance;\n}\n\n/**\n * Reset the cache singleton (for testing)\n */\nexport function resetEmbeddingCache(): void {\n if (cacheInstance) {\n cacheInstance.close();\n cacheInstance = null;\n }\n}\n"]}
|
|
@@ -5,10 +5,13 @@
|
|
|
5
5
|
* - SIMD128 acceleration (6x faster)
|
|
6
6
|
* - Parallel worker threads (7 workers)
|
|
7
7
|
* - all-MiniLM-L6-v2 model (384 dimensions)
|
|
8
|
+
* - Persistent SQLite cache (0.1ms vs 400ms)
|
|
8
9
|
*
|
|
9
10
|
* Configure via:
|
|
10
11
|
* - AGENTIC_FLOW_EMBEDDINGS=simple|onnx|auto (default: auto)
|
|
11
12
|
* - AGENTIC_FLOW_EMBEDDING_MODEL=all-MiniLM-L6-v2 (default)
|
|
13
|
+
* - AGENTIC_FLOW_EMBEDDING_CACHE=true|false (default: true)
|
|
14
|
+
* - AGENTIC_FLOW_PERSISTENT_CACHE=true|false (default: true)
|
|
12
15
|
*/
|
|
13
16
|
export type EmbeddingBackend = 'simple' | 'onnx' | 'auto';
|
|
14
17
|
export interface EmbeddingStats {
|
|
@@ -23,6 +26,14 @@ export interface EmbeddingStats {
|
|
|
23
26
|
modelName?: string;
|
|
24
27
|
simdAvailable?: boolean;
|
|
25
28
|
parallelWorkers?: number;
|
|
29
|
+
persistentCache?: {
|
|
30
|
+
enabled: boolean;
|
|
31
|
+
entries: number;
|
|
32
|
+
hits: number;
|
|
33
|
+
misses: number;
|
|
34
|
+
hitRate: number;
|
|
35
|
+
dbSizeKB: number;
|
|
36
|
+
};
|
|
26
37
|
}
|
|
27
38
|
export interface SimilarityResult {
|
|
28
39
|
similarity: number;
|
|
@@ -51,6 +62,8 @@ export declare class EmbeddingService {
|
|
|
51
62
|
private cacheHits;
|
|
52
63
|
private cache;
|
|
53
64
|
private cacheEnabled;
|
|
65
|
+
private persistentCache;
|
|
66
|
+
private persistentCacheEnabled;
|
|
54
67
|
private corpus;
|
|
55
68
|
private constructor();
|
|
56
69
|
static getInstance(): EmbeddingService;
|
|
@@ -137,9 +150,26 @@ export declare class EmbeddingService {
|
|
|
137
150
|
*/
|
|
138
151
|
getStats(): EmbeddingStats;
|
|
139
152
|
/**
|
|
140
|
-
* Clear cache
|
|
153
|
+
* Clear in-memory cache
|
|
141
154
|
*/
|
|
142
155
|
clearCache(): void;
|
|
156
|
+
/**
|
|
157
|
+
* Clear persistent cache (SQLite)
|
|
158
|
+
*/
|
|
159
|
+
clearPersistentCache(): void;
|
|
160
|
+
/**
|
|
161
|
+
* Clear all caches (memory + persistent)
|
|
162
|
+
*/
|
|
163
|
+
clearAllCaches(): void;
|
|
164
|
+
/**
|
|
165
|
+
* Get persistent cache stats
|
|
166
|
+
*/
|
|
167
|
+
getPersistentCacheStats(): {
|
|
168
|
+
entries: number;
|
|
169
|
+
hits: number;
|
|
170
|
+
misses: number;
|
|
171
|
+
hitRate: number;
|
|
172
|
+
} | null;
|
|
143
173
|
/**
|
|
144
174
|
* Clear corpus
|
|
145
175
|
*/
|
|
@@ -152,10 +182,192 @@ export declare class EmbeddingService {
|
|
|
152
182
|
* Reset instance (for testing)
|
|
153
183
|
*/
|
|
154
184
|
static reset(): Promise<void>;
|
|
185
|
+
/**
|
|
186
|
+
* Pretrain cache with texts from files
|
|
187
|
+
* Embeds content and stores in persistent cache for fast retrieval
|
|
188
|
+
*
|
|
189
|
+
* @param sources - File paths or glob patterns, or array of texts
|
|
190
|
+
* @param options - Pretrain options
|
|
191
|
+
* @returns Stats about pretraining
|
|
192
|
+
*/
|
|
193
|
+
pretrain(sources: string | string[], options?: {
|
|
194
|
+
batchSize?: number;
|
|
195
|
+
onProgress?: (processed: number, total: number) => void;
|
|
196
|
+
chunkSize?: number;
|
|
197
|
+
overlapSize?: number;
|
|
198
|
+
skipCached?: boolean;
|
|
199
|
+
}): Promise<{
|
|
200
|
+
processed: number;
|
|
201
|
+
cached: number;
|
|
202
|
+
skipped: number;
|
|
203
|
+
timeMs: number;
|
|
204
|
+
}>;
|
|
205
|
+
/**
|
|
206
|
+
* Pretrain with common programming patterns
|
|
207
|
+
* Pre-caches embeddings for frequently used code patterns
|
|
208
|
+
*/
|
|
209
|
+
pretrainCodePatterns(): Promise<{
|
|
210
|
+
cached: number;
|
|
211
|
+
timeMs: number;
|
|
212
|
+
}>;
|
|
213
|
+
/**
|
|
214
|
+
* Pretrain from repository structure
|
|
215
|
+
* Analyzes file names and paths to pre-cache common patterns
|
|
216
|
+
*/
|
|
217
|
+
pretrainFromRepo(repoPath?: string): Promise<{
|
|
218
|
+
files: number;
|
|
219
|
+
chunks: number;
|
|
220
|
+
timeMs: number;
|
|
221
|
+
}>;
|
|
222
|
+
/**
|
|
223
|
+
* Incremental pretrain - only process changed files since last run
|
|
224
|
+
* Uses git diff to detect modified files
|
|
225
|
+
*/
|
|
226
|
+
pretrainIncremental(options?: {
|
|
227
|
+
since?: string;
|
|
228
|
+
repoPath?: string;
|
|
229
|
+
}): Promise<{
|
|
230
|
+
changedFiles: number;
|
|
231
|
+
newChunks: number;
|
|
232
|
+
skipped: number;
|
|
233
|
+
timeMs: number;
|
|
234
|
+
}>;
|
|
235
|
+
/**
|
|
236
|
+
* Smart chunking - split code by semantic boundaries
|
|
237
|
+
* (functions, classes, etc.) instead of fixed size
|
|
238
|
+
*/
|
|
239
|
+
semanticChunk(content: string, fileType: string): string[];
|
|
240
|
+
/**
|
|
241
|
+
* Pretrain with semantic chunking
|
|
242
|
+
* Uses code structure to create meaningful chunks
|
|
243
|
+
*/
|
|
244
|
+
pretrainSemantic(sources: string[], options?: {
|
|
245
|
+
batchSize?: number;
|
|
246
|
+
onProgress?: (processed: number, total: number) => void;
|
|
247
|
+
}): Promise<{
|
|
248
|
+
files: number;
|
|
249
|
+
chunks: number;
|
|
250
|
+
timeMs: number;
|
|
251
|
+
}>;
|
|
252
|
+
/**
|
|
253
|
+
* Priority pretrain - cache most frequently used patterns first
|
|
254
|
+
* Tracks access patterns and prioritizes high-frequency queries
|
|
255
|
+
*/
|
|
256
|
+
private accessCounts;
|
|
257
|
+
recordAccess(text: string): void;
|
|
258
|
+
getTopPatterns(n?: number): string[];
|
|
259
|
+
pretrainPriority(n?: number): Promise<{
|
|
260
|
+
cached: number;
|
|
261
|
+
timeMs: number;
|
|
262
|
+
}>;
|
|
263
|
+
/**
|
|
264
|
+
* Warmup cache on session start
|
|
265
|
+
* Combines code patterns + recent repo changes
|
|
266
|
+
*/
|
|
267
|
+
warmup(repoPath?: string): Promise<{
|
|
268
|
+
patterns: number;
|
|
269
|
+
recentChanges: number;
|
|
270
|
+
timeMs: number;
|
|
271
|
+
}>;
|
|
272
|
+
/**
|
|
273
|
+
* Intelligent pretrain using ruvector worker pool
|
|
274
|
+
* Analyzes repo structure, code patterns, and prepares cache
|
|
275
|
+
* Uses parallel workers for maximum throughput
|
|
276
|
+
*/
|
|
277
|
+
pretrainIntelligent(options?: {
|
|
278
|
+
repoPath?: string;
|
|
279
|
+
parallel?: boolean;
|
|
280
|
+
onProgress?: (stage: string, progress: number) => void;
|
|
281
|
+
}): Promise<{
|
|
282
|
+
stages: {
|
|
283
|
+
codePatterns: {
|
|
284
|
+
count: number;
|
|
285
|
+
timeMs: number;
|
|
286
|
+
};
|
|
287
|
+
astAnalysis: {
|
|
288
|
+
files: number;
|
|
289
|
+
functions: number;
|
|
290
|
+
timeMs: number;
|
|
291
|
+
};
|
|
292
|
+
gitHistory: {
|
|
293
|
+
commits: number;
|
|
294
|
+
hotFiles: number;
|
|
295
|
+
timeMs: number;
|
|
296
|
+
};
|
|
297
|
+
dependencies: {
|
|
298
|
+
modules: number;
|
|
299
|
+
imports: number;
|
|
300
|
+
timeMs: number;
|
|
301
|
+
};
|
|
302
|
+
semanticChunks: {
|
|
303
|
+
chunks: number;
|
|
304
|
+
timeMs: number;
|
|
305
|
+
};
|
|
306
|
+
};
|
|
307
|
+
totalCached: number;
|
|
308
|
+
totalTimeMs: number;
|
|
309
|
+
}>;
|
|
310
|
+
/**
|
|
311
|
+
* Background pretrain - runs in worker if available
|
|
312
|
+
* Non-blocking, returns immediately with a promise
|
|
313
|
+
*/
|
|
314
|
+
pretrainBackground(options?: {
|
|
315
|
+
repoPath?: string;
|
|
316
|
+
}): {
|
|
317
|
+
promise: Promise<void>;
|
|
318
|
+
cancel: () => void;
|
|
319
|
+
};
|
|
320
|
+
/**
|
|
321
|
+
* AI-enhanced pretrain using ruvector attention mechanisms
|
|
322
|
+
* Uses HyperbolicAttention for code structure, MoE for routing
|
|
323
|
+
*/
|
|
324
|
+
pretrainWithAI(options?: {
|
|
325
|
+
repoPath?: string;
|
|
326
|
+
attentionType?: 'hyperbolic' | 'moe' | 'graph' | 'auto';
|
|
327
|
+
onProgress?: (stage: string, detail: string) => void;
|
|
328
|
+
}): Promise<{
|
|
329
|
+
patterns: {
|
|
330
|
+
type: string;
|
|
331
|
+
count: number;
|
|
332
|
+
}[];
|
|
333
|
+
attention: {
|
|
334
|
+
type: string;
|
|
335
|
+
timeMs: number;
|
|
336
|
+
};
|
|
337
|
+
predictions: {
|
|
338
|
+
prefetch: number;
|
|
339
|
+
confidence: number;
|
|
340
|
+
};
|
|
341
|
+
totalCached: number;
|
|
342
|
+
totalTimeMs: number;
|
|
343
|
+
}>;
|
|
344
|
+
/**
|
|
345
|
+
* Context-aware prefetch using attention
|
|
346
|
+
* Predicts what embeddings will be needed based on current context
|
|
347
|
+
*/
|
|
348
|
+
prefetchForContext(context: {
|
|
349
|
+
currentFile?: string;
|
|
350
|
+
recentFiles?: string[];
|
|
351
|
+
taskType?: 'edit' | 'review' | 'debug' | 'test' | 'refactor';
|
|
352
|
+
userQuery?: string;
|
|
353
|
+
}): Promise<{
|
|
354
|
+
prefetched: number;
|
|
355
|
+
confidence: number;
|
|
356
|
+
timeMs: number;
|
|
357
|
+
}>;
|
|
155
358
|
}
|
|
156
359
|
export declare function getEmbeddingService(): EmbeddingService;
|
|
157
360
|
export declare function embed(text: string): Promise<Float32Array>;
|
|
158
361
|
export declare function embedBatch(texts: string[]): Promise<Float32Array[]>;
|
|
362
|
+
export declare function pretrainCodePatterns(): Promise<{
|
|
363
|
+
cached: number;
|
|
364
|
+
timeMs: number;
|
|
365
|
+
}>;
|
|
366
|
+
export declare function pretrainFromRepo(repoPath?: string): Promise<{
|
|
367
|
+
files: number;
|
|
368
|
+
chunks: number;
|
|
369
|
+
timeMs: number;
|
|
370
|
+
}>;
|
|
159
371
|
export declare function textSimilarity(text1: string, text2: string): Promise<number>;
|
|
160
372
|
export declare function simpleEmbed(text: string, dim?: number): Float32Array;
|
|
161
373
|
export declare function similarityMatrix(texts: string[]): Promise<number[][]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmbeddingService.d.ts","sourceRoot":"","sources":["../../src/intelligence/EmbeddingService.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"EmbeddingService.d.ts","sourceRoot":"","sources":["../../src/intelligence/EmbeddingService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAE1D,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,gBAAgB,CAAC;IAC1B,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACr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