@edihasaj/recall 1.0.8 → 1.0.9
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/{chunk-O52XDFLI.js → chunk-KD4OKHYF.js} +101 -21
- package/dist/chunk-KD4OKHYF.js.map +1 -0
- package/dist/{chunk-LKFQ4W3R.js → chunk-LYTIYKXH.js} +2 -2
- package/dist/{chunk-3AXRO4H4.js → chunk-PGTHECO2.js} +3 -3
- package/dist/{chunk-ICF4ZPAO.js → chunk-QAFWA4U6.js} +6 -6
- package/dist/{chunk-63DJ3SBO.js → chunk-SGL4ZDGZ.js} +7 -7
- package/dist/{chunk-B2FPSWII.js → chunk-TGWUGUVH.js} +3 -3
- package/dist/{chunk-HKODGJ25.js → chunk-TYXRTMDK.js} +3 -3
- package/dist/{chunk-4XP6POJG.js → chunk-WD55NWCC.js} +2 -2
- package/dist/{chunk-6RJ3RYKH.js → chunk-YC64D4QN.js} +44 -22
- package/dist/{chunk-6RJ3RYKH.js.map → chunk-YC64D4QN.js.map} +1 -1
- package/dist/{cleanup-FT4VSAVQ.js → cleanup-OJBSLUMO.js} +4 -4
- package/dist/cli.js +18 -18
- package/dist/daemon.js +11 -11
- package/dist/daemon.js.map +1 -1
- package/dist/{dispatcher-EPRCW6DH.js → dispatcher-IIFTDIOW.js} +4 -4
- package/dist/{embeddings-ZBTV5M2O.js → embeddings-CLBTYK7N.js} +4 -2
- package/dist/{ingest-5N3L72OM.js → ingest-NX53XWCU.js} +3 -3
- package/dist/mcp.js +7 -7
- package/dist/{memory-value-CHMQBOGG.js → memory-value-LISBUR2V.js} +4 -4
- package/dist/{quality-N6LN7DNU.js → quality-TM5E6JCK.js} +5 -5
- package/dist/{retrieval-G5WXWBOW.js → retrieval-63A775WR.js} +4 -4
- package/dist/{tasks-32Y37M27.js → tasks-UEROYP6D.js} +4 -4
- package/package.json +1 -1
- package/dist/chunk-O52XDFLI.js.map +0 -1
- /package/dist/{chunk-LKFQ4W3R.js.map → chunk-LYTIYKXH.js.map} +0 -0
- /package/dist/{chunk-3AXRO4H4.js.map → chunk-PGTHECO2.js.map} +0 -0
- /package/dist/{chunk-ICF4ZPAO.js.map → chunk-QAFWA4U6.js.map} +0 -0
- /package/dist/{chunk-63DJ3SBO.js.map → chunk-SGL4ZDGZ.js.map} +0 -0
- /package/dist/{chunk-B2FPSWII.js.map → chunk-TGWUGUVH.js.map} +0 -0
- /package/dist/{chunk-HKODGJ25.js.map → chunk-TYXRTMDK.js.map} +0 -0
- /package/dist/{chunk-4XP6POJG.js.map → chunk-WD55NWCC.js.map} +0 -0
- /package/dist/{cleanup-FT4VSAVQ.js.map → cleanup-OJBSLUMO.js.map} +0 -0
- /package/dist/{dispatcher-EPRCW6DH.js.map → dispatcher-IIFTDIOW.js.map} +0 -0
- /package/dist/{embeddings-ZBTV5M2O.js.map → embeddings-CLBTYK7N.js.map} +0 -0
- /package/dist/{ingest-5N3L72OM.js.map → ingest-NX53XWCU.js.map} +0 -0
- /package/dist/{memory-value-CHMQBOGG.js.map → memory-value-LISBUR2V.js.map} +0 -0
- /package/dist/{quality-N6LN7DNU.js.map → quality-TM5E6JCK.js.map} +0 -0
- /package/dist/{retrieval-G5WXWBOW.js.map → retrieval-63A775WR.js.map} +0 -0
- /package/dist/{tasks-32Y37M27.js.map → tasks-UEROYP6D.js.map} +0 -0
|
@@ -859,6 +859,26 @@ function resolveProvider(config) {
|
|
|
859
859
|
|
|
860
860
|
// src/vector/sqlite-vec.ts
|
|
861
861
|
import * as sqliteVec from "sqlite-vec";
|
|
862
|
+
|
|
863
|
+
// src/embeddings/responsive-batches.ts
|
|
864
|
+
var BACKGROUND_EMBEDDING_BATCH_SIZE = 1;
|
|
865
|
+
var BACKGROUND_INDEX_BATCH_SIZE = 32;
|
|
866
|
+
function yieldToEventLoop() {
|
|
867
|
+
return new Promise((resolve) => setImmediate(resolve));
|
|
868
|
+
}
|
|
869
|
+
async function processInResponsiveBatches(items, processBatch, options = {}) {
|
|
870
|
+
const batchSize = options.batchSize ?? BACKGROUND_EMBEDDING_BATCH_SIZE;
|
|
871
|
+
const yieldControl = options.yieldControl ?? yieldToEventLoop;
|
|
872
|
+
if (!Number.isInteger(batchSize) || batchSize <= 0) {
|
|
873
|
+
throw new Error(`Invalid background embedding batch size: ${batchSize}`);
|
|
874
|
+
}
|
|
875
|
+
for (let i = 0; i < items.length; i += batchSize) {
|
|
876
|
+
await processBatch(items.slice(i, i + batchSize));
|
|
877
|
+
if (i + batchSize < items.length) await yieldControl();
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
// src/vector/sqlite-vec.ts
|
|
862
882
|
var VEC_MEMORY_INDEX = "vec_memory_index";
|
|
863
883
|
var loadedClients = /* @__PURE__ */ new WeakSet();
|
|
864
884
|
function getSqlite(db) {
|
|
@@ -986,6 +1006,50 @@ function rebuildMemoryVecIndex(db, config, options = {}) {
|
|
|
986
1006
|
insertMany(rows);
|
|
987
1007
|
return rows.length;
|
|
988
1008
|
}
|
|
1009
|
+
async function rebuildMemoryVecIndexResponsive(db, config, options = {}) {
|
|
1010
|
+
const rows = db.select({
|
|
1011
|
+
id: memories.id,
|
|
1012
|
+
repo: memories.repo,
|
|
1013
|
+
status: memories.status,
|
|
1014
|
+
type: memories.type,
|
|
1015
|
+
scope: memories.scope,
|
|
1016
|
+
index_dimensions: memoryEmbeddings.index_dimensions,
|
|
1017
|
+
embedding: memoryEmbeddings.embedding
|
|
1018
|
+
}).from(memories).innerJoin(memoryEmbeddings, eq(memoryEmbeddings.memory_id, memories.id)).all().filter((row) => !options.repo || row.repo === options.repo);
|
|
1019
|
+
const targetDimension = getMemoryVecDimension(rows) ?? config.dimensions;
|
|
1020
|
+
if (options.repo) {
|
|
1021
|
+
if (rows.length > 0) ensureMemoryVecIndex(db, targetDimension);
|
|
1022
|
+
if (!hasMemoryVecIndex(db)) return 0;
|
|
1023
|
+
getSqlite(db).prepare(`delete from ${VEC_MEMORY_INDEX} where repo = ?`).run(options.repo);
|
|
1024
|
+
if (rows.length === 0) return 0;
|
|
1025
|
+
} else {
|
|
1026
|
+
dropMemoryVecIndex(db);
|
|
1027
|
+
ensureMemoryVecIndex(db, targetDimension);
|
|
1028
|
+
}
|
|
1029
|
+
const sqlite = getSqlite(db);
|
|
1030
|
+
const stmt = sqlite.prepare(`
|
|
1031
|
+
insert into ${VEC_MEMORY_INDEX} (embedding, memory_id, repo, status, type, scope)
|
|
1032
|
+
values (?, ?, ?, ?, ?, ?)
|
|
1033
|
+
`);
|
|
1034
|
+
const insertMany = sqlite.transaction((batch) => {
|
|
1035
|
+
for (const row of batch) {
|
|
1036
|
+
stmt.run(
|
|
1037
|
+
projectIndexBuffer(row.embedding, row.index_dimensions),
|
|
1038
|
+
row.id,
|
|
1039
|
+
row.repo ?? "",
|
|
1040
|
+
row.status,
|
|
1041
|
+
row.type,
|
|
1042
|
+
row.scope
|
|
1043
|
+
);
|
|
1044
|
+
}
|
|
1045
|
+
});
|
|
1046
|
+
await processInResponsiveBatches(rows, async (batch) => {
|
|
1047
|
+
insertMany(batch);
|
|
1048
|
+
}, {
|
|
1049
|
+
batchSize: BACKGROUND_INDEX_BATCH_SIZE
|
|
1050
|
+
});
|
|
1051
|
+
return rows.length;
|
|
1052
|
+
}
|
|
989
1053
|
function projectIndexBuffer(buffer, indexDimensions) {
|
|
990
1054
|
const embedding = new Float32Array(
|
|
991
1055
|
buffer.buffer,
|
|
@@ -1433,6 +1497,32 @@ function rebuildMemoryFtsIndex(db, options = {}) {
|
|
|
1433
1497
|
insertMany(rows);
|
|
1434
1498
|
return rows.length;
|
|
1435
1499
|
}
|
|
1500
|
+
async function rebuildMemoryFtsIndexResponsive(db, options = {}) {
|
|
1501
|
+
if (options.repo) {
|
|
1502
|
+
ensureMemoryFtsIndex(db);
|
|
1503
|
+
getSqlite2(db).prepare(`delete from ${FTS_MEMORY_INDEX} where repo = ?`).run(options.repo);
|
|
1504
|
+
} else {
|
|
1505
|
+
dropMemoryFtsIndex(db);
|
|
1506
|
+
ensureMemoryFtsIndex(db);
|
|
1507
|
+
}
|
|
1508
|
+
const rows = db.select().from(memories).all().filter((row) => !options.repo || row.repo === options.repo).filter((row) => shouldIndexLexically(row));
|
|
1509
|
+
const sqlite = getSqlite2(db);
|
|
1510
|
+
const stmt = sqlite.prepare(`
|
|
1511
|
+
insert into ${FTS_MEMORY_INDEX} (memory_id, text, repo, status, type, scope, path_scope)
|
|
1512
|
+
values (?, ?, ?, ?, ?, ?, ?)
|
|
1513
|
+
`);
|
|
1514
|
+
const insertMany = sqlite.transaction((batch) => {
|
|
1515
|
+
for (const row of batch) {
|
|
1516
|
+
stmt.run(row.id, row.text, row.repo ?? "", row.status, row.type, row.scope, row.path_scope ?? "");
|
|
1517
|
+
}
|
|
1518
|
+
});
|
|
1519
|
+
await processInResponsiveBatches(rows, async (batch) => {
|
|
1520
|
+
insertMany(batch);
|
|
1521
|
+
}, {
|
|
1522
|
+
batchSize: BACKGROUND_INDEX_BATCH_SIZE
|
|
1523
|
+
});
|
|
1524
|
+
return rows.length;
|
|
1525
|
+
}
|
|
1436
1526
|
function verifyMemoryFtsIndex(db, options = {}) {
|
|
1437
1527
|
const sqlite = getSqlite2(db);
|
|
1438
1528
|
const exists = sqlite.prepare("select 1 from sqlite_master where type = 'table' and name = ?").get(FTS_MEMORY_INDEX);
|
|
@@ -1912,23 +2002,6 @@ async function rerankPairs(query, documents) {
|
|
|
1912
2002
|
});
|
|
1913
2003
|
}
|
|
1914
2004
|
|
|
1915
|
-
// src/embeddings/responsive-batches.ts
|
|
1916
|
-
var BACKGROUND_EMBEDDING_BATCH_SIZE = 1;
|
|
1917
|
-
function yieldToEventLoop() {
|
|
1918
|
-
return new Promise((resolve) => setImmediate(resolve));
|
|
1919
|
-
}
|
|
1920
|
-
async function processInResponsiveBatches(items, processBatch, options = {}) {
|
|
1921
|
-
const batchSize = options.batchSize ?? BACKGROUND_EMBEDDING_BATCH_SIZE;
|
|
1922
|
-
const yieldControl = options.yieldControl ?? yieldToEventLoop;
|
|
1923
|
-
if (!Number.isInteger(batchSize) || batchSize <= 0) {
|
|
1924
|
-
throw new Error(`Invalid background embedding batch size: ${batchSize}`);
|
|
1925
|
-
}
|
|
1926
|
-
for (let i = 0; i < items.length; i += batchSize) {
|
|
1927
|
-
await processBatch(items.slice(i, i + batchSize));
|
|
1928
|
-
if (i + batchSize < items.length) await yieldControl();
|
|
1929
|
-
}
|
|
1930
|
-
}
|
|
1931
|
-
|
|
1932
2005
|
// src/embeddings/embeddings.ts
|
|
1933
2006
|
var MIN_HYBRID_VECTOR_SIMILARITY = (() => {
|
|
1934
2007
|
const raw = process.env.RECALL_HYBRID_MIN_SIM;
|
|
@@ -2169,8 +2242,8 @@ async function bootstrapEmbeddings(db, config, options = {}) {
|
|
|
2169
2242
|
total++;
|
|
2170
2243
|
}
|
|
2171
2244
|
});
|
|
2172
|
-
|
|
2173
|
-
|
|
2245
|
+
await rebuildMemoryFtsIndexResponsive(db, options);
|
|
2246
|
+
await rebuildMemoryVecIndexResponsive(db, config, options);
|
|
2174
2247
|
return total;
|
|
2175
2248
|
}
|
|
2176
2249
|
function verifyEmbeddings(db, config, options = {}) {
|
|
@@ -2211,6 +2284,11 @@ function rebuildEmbeddingIndex(db, config, options = {}) {
|
|
|
2211
2284
|
lexical_rows: lexicalRows
|
|
2212
2285
|
};
|
|
2213
2286
|
}
|
|
2287
|
+
async function rebuildEmbeddingIndexResponsive(db, config, options = {}) {
|
|
2288
|
+
const lexicalRows = await rebuildMemoryFtsIndexResponsive(db, options);
|
|
2289
|
+
const vectorRows = config ? await rebuildMemoryVecIndexResponsive(db, config, options) : 0;
|
|
2290
|
+
return { vector_rows: vectorRows, lexical_rows: lexicalRows };
|
|
2291
|
+
}
|
|
2214
2292
|
function lexicalRankToScore(rank, position) {
|
|
2215
2293
|
const safeRank = Number.isFinite(rank) ? Math.abs(rank) : position + 1;
|
|
2216
2294
|
return 1 / (1 + safeRank + position);
|
|
@@ -2418,6 +2496,8 @@ export {
|
|
|
2418
2496
|
RetrievalEvalCase,
|
|
2419
2497
|
RetrievalEvalFile,
|
|
2420
2498
|
resolveProvider,
|
|
2499
|
+
BACKGROUND_INDEX_BATCH_SIZE,
|
|
2500
|
+
processInResponsiveBatches,
|
|
2421
2501
|
getSynonyms,
|
|
2422
2502
|
searchMemoryFtsIndex,
|
|
2423
2503
|
LlmCredentialError,
|
|
@@ -2425,7 +2505,6 @@ export {
|
|
|
2425
2505
|
callLlm,
|
|
2426
2506
|
readUtf8FileIfExists,
|
|
2427
2507
|
atomicWriteUtf8File,
|
|
2428
|
-
processInResponsiveBatches,
|
|
2429
2508
|
loadEmbeddingConfigFromEnv,
|
|
2430
2509
|
getEmbeddingModelInfo,
|
|
2431
2510
|
ensureEmbeddingProviderReady,
|
|
@@ -2441,10 +2520,11 @@ export {
|
|
|
2441
2520
|
bootstrapEmbeddings,
|
|
2442
2521
|
verifyEmbeddings,
|
|
2443
2522
|
rebuildEmbeddingIndex,
|
|
2523
|
+
rebuildEmbeddingIndexResponsive,
|
|
2444
2524
|
hybridSearch,
|
|
2445
2525
|
cosineSimilarity,
|
|
2446
2526
|
semanticSearch,
|
|
2447
2527
|
findSemanticDuplicates,
|
|
2448
2528
|
findSimilarRejectedExemplar
|
|
2449
2529
|
};
|
|
2450
|
-
//# sourceMappingURL=chunk-
|
|
2530
|
+
//# sourceMappingURL=chunk-KD4OKHYF.js.map
|