@yugenlab/vaayu 0.1.10 → 0.1.12
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/chunks/{agentic-tool-loop-2FZK72JO.js → agentic-tool-loop-NQESOBLC.js} +2 -2
- package/chunks/akasha-5C5Q6NMP.js +12 -0
- package/chunks/{chunk-JGI4SDWS.js → chunk-26K6DS6N.js} +7 -5
- package/chunks/chunk-5E3ZS5SW.js +529 -0
- package/chunks/{chunk-VJHNE47S.js → chunk-ARZCIITZ.js} +104 -94
- package/chunks/{chunk-PRXQW76U.js → chunk-EG37M4QL.js} +17 -6
- package/chunks/{chunk-HIYHTWFW.js → chunk-FEDPZOZ5.js} +572 -441
- package/chunks/{chunk-O4KV7TFP.js → chunk-GWYC7R2L.js} +38 -20
- package/chunks/chunk-H46F2Y6R.js +134 -0
- package/chunks/{chunk-M7THR63C.js → chunk-HXHDP2PZ.js} +78 -65
- package/chunks/chunk-KVQH4LE7.js +396 -0
- package/chunks/{chunk-TND3MU4Z.js → chunk-LJCT7UYP.js} +86 -68
- package/chunks/{chunk-OT4G2L46.js → chunk-M2RLX5LU.js} +229 -163
- package/chunks/{chunk-IGKYKEKT.js → chunk-NAQKA54E.js} +8 -2
- package/chunks/{chunk-77725AR7.js → chunk-PZ4AQ22L.js} +151 -57
- package/chunks/{chunk-C76USAC5.js → chunk-QFGAB4XD.js} +13 -5
- package/chunks/{chunk-MJ74G5RB.js → chunk-R273KC7J.js} +276 -3
- package/chunks/{chunk-JAWZ7ANC.js → chunk-RVKTGKFD.js} +12 -8
- package/chunks/{chunk-AGK3A7R7.js → chunk-TSOQ2CT3.js} +1430 -1173
- package/chunks/{chunk-YJRXLRTE.js → chunk-VEZ2DI2M.js} +24 -12
- package/chunks/{chunk-N22M7D4P.js → chunk-XP3NIH5F.js} +91 -98
- package/chunks/{chunk-6556EKOB.js → chunk-Y6IZH6FT.js} +42 -26
- package/chunks/{chunk-AS3DJFY3.js → chunk-YRTGGYJU.js} +45 -41
- package/chunks/{consolidation-indexer-VKQ6DNU3.js → consolidation-indexer-KPXORCJ4.js} +9 -9
- package/chunks/database-BX3LVYXS.js +11 -0
- package/chunks/{day-consolidation-BH3QU2SZ.js → day-consolidation-CR3TJFAL.js} +5 -5
- package/chunks/{src-Y3TGMINC.js → dist-ESCM3CP5.js} +31 -21
- package/chunks/graphrag-73XA7LBX.js +14 -0
- package/chunks/hierarchical-temporal-search-GHKVKNZ6.js +8 -0
- package/chunks/hybrid-search-OD756RDV.js +20 -0
- package/chunks/{memory-store-A6WOWLWC.js → memory-store-4GCBR2DZ.js} +4 -4
- package/chunks/periodic-consolidation-IINCHP6L.js +11 -0
- package/chunks/postgres-YLCUNVPQ.js +8 -0
- package/chunks/recall-64RROTUC.js +21 -0
- package/chunks/search-JVCDNTAJ.js +19 -0
- package/chunks/{session-store-3BRPGC6P.js → session-store-3EDQZEDS.js} +12 -6
- package/chunks/{sqlite-DHUQGPR5.js → sqlite-4N7YH2KK.js} +3 -3
- package/chunks/{src-6GVZTUH6.js → src-OPSDZEFI.js} +2 -2
- package/chunks/{suncalc-NOHGYHDU.js → suncalc-RM7URNUR.js} +2 -2
- package/chunks/{tree-RSHKDTCR.js → tree-FIUVGJ5J.js} +2 -2
- package/chunks/{vasana-engine-MU25OQ23.js → vasana-engine-W4PYWT5H.js} +5 -5
- package/gateway.js +38859 -30650
- package/package.json +1 -1
- package/pair-cli.js +2 -2
- package/chunks/chunk-U62ABYKD.js +0 -123
- package/chunks/chunk-UZ6OIVEC.js +0 -198
- package/chunks/graphrag-D7OXWAWD.js +0 -14
- package/chunks/hierarchical-temporal-search-PVHVA3NZ.js +0 -8
- package/chunks/hybrid-search-G2NAJKJ7.js +0 -20
- package/chunks/periodic-consolidation-LMYMNS4Q.js +0 -11
- package/chunks/postgres-WLH3D5HG.js +0 -8
- package/chunks/recall-ZNL4DJ2L.js +0 -21
- package/chunks/search-35JMSGUT.js +0 -19
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getMemory,
|
|
3
3
|
listMemoryScopes
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-Y6IZH6FT.js";
|
|
5
5
|
import {
|
|
6
|
+
init_session_store,
|
|
6
7
|
listSessions,
|
|
7
8
|
loadSession
|
|
8
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-FEDPZOZ5.js";
|
|
9
10
|
import {
|
|
10
|
-
initAgentSchema
|
|
11
|
-
|
|
11
|
+
initAgentSchema,
|
|
12
|
+
init_schema
|
|
13
|
+
} from "./chunk-VEZ2DI2M.js";
|
|
12
14
|
import {
|
|
13
|
-
DatabaseManager
|
|
14
|
-
|
|
15
|
+
DatabaseManager,
|
|
16
|
+
init_database
|
|
17
|
+
} from "./chunk-H46F2Y6R.js";
|
|
15
18
|
|
|
16
|
-
// ../chitragupta/packages/smriti/
|
|
19
|
+
// ../chitragupta/packages/smriti/dist/search.js
|
|
20
|
+
init_session_store();
|
|
21
|
+
init_database();
|
|
22
|
+
init_schema();
|
|
17
23
|
var _dbInitialized = false;
|
|
18
24
|
function getAgentDb() {
|
|
19
25
|
const dbm = DatabaseManager.instance();
|
|
@@ -34,16 +40,20 @@ function _resetSearchDbInit() {
|
|
|
34
40
|
}
|
|
35
41
|
function sanitizeFts5Query(query) {
|
|
36
42
|
const cleaned = query.replace(/[*^"(){}:]/g, "").replace(/\b(NOT|AND|OR|NEAR)\b/gi, "").trim();
|
|
37
|
-
if (!cleaned)
|
|
43
|
+
if (!cleaned)
|
|
44
|
+
return "";
|
|
38
45
|
const terms = cleaned.split(/\s+/).filter((t) => t.length >= 2).map((t) => `"${t}"`).join(" ");
|
|
39
46
|
return terms;
|
|
40
47
|
}
|
|
41
48
|
function recencyBoost(epochMs) {
|
|
42
49
|
const ageMs = Date.now() - epochMs;
|
|
43
50
|
const ageHours = ageMs / (1e3 * 60 * 60);
|
|
44
|
-
if (ageHours < 1)
|
|
45
|
-
|
|
46
|
-
if (ageHours <
|
|
51
|
+
if (ageHours < 1)
|
|
52
|
+
return 1.5 - 0.2 * (ageHours / 1);
|
|
53
|
+
if (ageHours < 24)
|
|
54
|
+
return 1.3 - 0.2 * ((ageHours - 1) / 23);
|
|
55
|
+
if (ageHours < 168)
|
|
56
|
+
return 1.1 - 0.1 * ((ageHours - 24) / 144);
|
|
47
57
|
return 1;
|
|
48
58
|
}
|
|
49
59
|
function recencyBoostIso(isoDate) {
|
|
@@ -201,7 +211,8 @@ var BM25Corpus = class {
|
|
|
201
211
|
let score = 0;
|
|
202
212
|
for (const term of queryTerms) {
|
|
203
213
|
const tf = doc.tf.get(term) ?? 0;
|
|
204
|
-
if (tf === 0)
|
|
214
|
+
if (tf === 0)
|
|
215
|
+
continue;
|
|
205
216
|
const idf = this.idf(term);
|
|
206
217
|
const numerator = tf * (BM25_K1 + 1);
|
|
207
218
|
const denominator = tf + BM25_K1 * (1 - BM25_B + BM25_B * (doc.length / (this.avgDl || 1)));
|
|
@@ -211,18 +222,21 @@ var BM25Corpus = class {
|
|
|
211
222
|
}
|
|
212
223
|
query(queryText) {
|
|
213
224
|
const queryTerms = tokenize(queryText);
|
|
214
|
-
if (queryTerms.length === 0)
|
|
225
|
+
if (queryTerms.length === 0)
|
|
226
|
+
return [];
|
|
215
227
|
const results = [];
|
|
216
228
|
for (const doc of this.documents) {
|
|
217
229
|
const score = this.scoreDocument(doc, queryTerms);
|
|
218
|
-
if (score > 0)
|
|
230
|
+
if (score > 0)
|
|
231
|
+
results.push({ payload: doc.payload, score });
|
|
219
232
|
}
|
|
220
233
|
results.sort((a, b) => b.score - a.score);
|
|
221
234
|
return results;
|
|
222
235
|
}
|
|
223
236
|
};
|
|
224
237
|
function searchSessions(query, project) {
|
|
225
|
-
if (!query || query.trim().length === 0)
|
|
238
|
+
if (!query || query.trim().length === 0)
|
|
239
|
+
return [];
|
|
226
240
|
try {
|
|
227
241
|
return searchSessionsFts5(query, project);
|
|
228
242
|
} catch (err) {
|
|
@@ -233,7 +247,8 @@ function searchSessions(query, project) {
|
|
|
233
247
|
}
|
|
234
248
|
function searchSessionsFts5(query, project) {
|
|
235
249
|
const ftsQuery = sanitizeFts5Query(query);
|
|
236
|
-
if (!ftsQuery)
|
|
250
|
+
if (!ftsQuery)
|
|
251
|
+
return [];
|
|
237
252
|
const db = getAgentDb();
|
|
238
253
|
const sql = project ? `SELECT t.session_id, t.turn_number, t.content, f.rank,
|
|
239
254
|
s.title, s.project, s.created_at, s.updated_at,
|
|
@@ -318,20 +333,23 @@ function searchSessionsBm25(query, project) {
|
|
|
318
333
|
return boosted.map((s) => s.meta);
|
|
319
334
|
}
|
|
320
335
|
function searchMemory(query) {
|
|
321
|
-
if (!query || query.trim().length === 0)
|
|
336
|
+
if (!query || query.trim().length === 0)
|
|
337
|
+
return [];
|
|
322
338
|
const scopes = listMemoryScopes();
|
|
323
339
|
const corpus = new BM25Corpus();
|
|
324
340
|
for (const scope of scopes) {
|
|
325
341
|
try {
|
|
326
342
|
const content = getMemory(scope);
|
|
327
|
-
if (!content)
|
|
343
|
+
if (!content)
|
|
344
|
+
continue;
|
|
328
345
|
corpus.addDocument({ scope, content }, content);
|
|
329
346
|
} catch {
|
|
330
347
|
}
|
|
331
348
|
}
|
|
332
349
|
corpus.finalize();
|
|
333
350
|
const results = corpus.query(query);
|
|
334
|
-
if (results.length === 0)
|
|
351
|
+
if (results.length === 0)
|
|
352
|
+
return [];
|
|
335
353
|
const maxScore = results[0].score;
|
|
336
354
|
return results.map((r) => ({
|
|
337
355
|
scope: r.payload.scope,
|
|
@@ -346,4 +364,4 @@ export {
|
|
|
346
364
|
searchSessions,
|
|
347
365
|
searchMemory
|
|
348
366
|
};
|
|
349
|
-
//# sourceMappingURL=chunk-
|
|
367
|
+
//# sourceMappingURL=chunk-GWYC7R2L.js.map
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getChitraguptaHome,
|
|
3
|
+
init_dist
|
|
4
|
+
} from "./chunk-KVQH4LE7.js";
|
|
5
|
+
import {
|
|
6
|
+
__esm
|
|
7
|
+
} from "./chunk-NAQKA54E.js";
|
|
8
|
+
|
|
9
|
+
// ../chitragupta/packages/smriti/dist/db/database.js
|
|
10
|
+
import Database from "better-sqlite3";
|
|
11
|
+
import fs from "fs";
|
|
12
|
+
import path from "path";
|
|
13
|
+
var DEFAULT_PRAGMAS, DatabaseManager;
|
|
14
|
+
var init_database = __esm({
|
|
15
|
+
"../chitragupta/packages/smriti/dist/db/database.js"() {
|
|
16
|
+
init_dist();
|
|
17
|
+
DEFAULT_PRAGMAS = {
|
|
18
|
+
journal_mode: "WAL",
|
|
19
|
+
synchronous: "NORMAL",
|
|
20
|
+
// Safe with WAL — fsync on checkpoint only
|
|
21
|
+
cache_size: -64e3,
|
|
22
|
+
// 64MB cache (negative = KB)
|
|
23
|
+
foreign_keys: 1,
|
|
24
|
+
busy_timeout: 5e3,
|
|
25
|
+
// 5s wait on lock contention
|
|
26
|
+
temp_store: "MEMORY",
|
|
27
|
+
mmap_size: 268435456
|
|
28
|
+
// 256MB mmap for read performance
|
|
29
|
+
};
|
|
30
|
+
DatabaseManager = class _DatabaseManager {
|
|
31
|
+
static _instance = null;
|
|
32
|
+
_databases = /* @__PURE__ */ new Map();
|
|
33
|
+
_dbDir;
|
|
34
|
+
_closed = false;
|
|
35
|
+
constructor(dbDir) {
|
|
36
|
+
this._dbDir = dbDir ?? getChitraguptaHome();
|
|
37
|
+
fs.mkdirSync(this._dbDir, { recursive: true });
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get or create the singleton instance.
|
|
41
|
+
* @param dbDir - Override the database directory (useful for testing).
|
|
42
|
+
*/
|
|
43
|
+
static instance(dbDir) {
|
|
44
|
+
if (!_DatabaseManager._instance || _DatabaseManager._instance._closed) {
|
|
45
|
+
_DatabaseManager._instance = new _DatabaseManager(dbDir);
|
|
46
|
+
}
|
|
47
|
+
return _DatabaseManager._instance;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Reset the singleton (for testing). Closes all open databases.
|
|
51
|
+
*/
|
|
52
|
+
static reset() {
|
|
53
|
+
if (_DatabaseManager._instance) {
|
|
54
|
+
_DatabaseManager._instance.closeAll();
|
|
55
|
+
_DatabaseManager._instance = null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get a database connection by name. Opens it on first access.
|
|
60
|
+
*/
|
|
61
|
+
get(name) {
|
|
62
|
+
if (this._closed) {
|
|
63
|
+
throw new Error("DatabaseManager has been closed");
|
|
64
|
+
}
|
|
65
|
+
let db = this._databases.get(name);
|
|
66
|
+
if (!db) {
|
|
67
|
+
db = this._open(name);
|
|
68
|
+
this._databases.set(name, db);
|
|
69
|
+
}
|
|
70
|
+
return db;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get the file path for a database.
|
|
74
|
+
*/
|
|
75
|
+
getPath(name) {
|
|
76
|
+
return path.join(this._dbDir, `${name}.db`);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Close all open database connections.
|
|
80
|
+
*/
|
|
81
|
+
closeAll() {
|
|
82
|
+
for (const [name, db] of this._databases) {
|
|
83
|
+
try {
|
|
84
|
+
db.close();
|
|
85
|
+
} catch {
|
|
86
|
+
}
|
|
87
|
+
this._databases.delete(name);
|
|
88
|
+
}
|
|
89
|
+
this._closed = true;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Close a specific database connection.
|
|
93
|
+
*/
|
|
94
|
+
close(name) {
|
|
95
|
+
const db = this._databases.get(name);
|
|
96
|
+
if (db) {
|
|
97
|
+
db.close();
|
|
98
|
+
this._databases.delete(name);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Run VACUUM on a database to reclaim space.
|
|
103
|
+
* Should be called during deep sleep / yearly archival.
|
|
104
|
+
*/
|
|
105
|
+
vacuum(name) {
|
|
106
|
+
this.get(name).exec("VACUUM");
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Check database integrity.
|
|
110
|
+
*/
|
|
111
|
+
integrityCheck(name) {
|
|
112
|
+
const result = this.get(name).pragma("integrity_check");
|
|
113
|
+
return result[0]?.integrity_check ?? "unknown";
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Open a database file and apply pragmas.
|
|
117
|
+
*/
|
|
118
|
+
_open(name) {
|
|
119
|
+
const dbPath = this.getPath(name);
|
|
120
|
+
const db = new Database(dbPath);
|
|
121
|
+
for (const [key, value] of Object.entries(DEFAULT_PRAGMAS)) {
|
|
122
|
+
db.pragma(`${key} = ${value}`);
|
|
123
|
+
}
|
|
124
|
+
return db;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
export {
|
|
131
|
+
DatabaseManager,
|
|
132
|
+
init_database
|
|
133
|
+
};
|
|
134
|
+
//# sourceMappingURL=chunk-H46F2Y6R.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
searchSessions
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GWYC7R2L.js";
|
|
4
4
|
|
|
5
|
-
// ../chitragupta/packages/smriti/
|
|
5
|
+
// ../chitragupta/packages/smriti/dist/hybrid-search-learner.js
|
|
6
6
|
function gaussianRandom() {
|
|
7
7
|
const u1 = Math.random();
|
|
8
8
|
const u2 = Math.random();
|
|
@@ -25,14 +25,17 @@ function sampleGamma(shape) {
|
|
|
25
25
|
v = v * v * v;
|
|
26
26
|
const u = Math.random();
|
|
27
27
|
const zSq = z * z;
|
|
28
|
-
if (u < 1 - 0.0331 * (zSq * zSq))
|
|
29
|
-
|
|
28
|
+
if (u < 1 - 0.0331 * (zSq * zSq))
|
|
29
|
+
return d * v;
|
|
30
|
+
if (Math.log(u) < 0.5 * zSq + d * (1 - v + Math.log(v)))
|
|
31
|
+
return d * v;
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
function sampleBeta(alpha, beta) {
|
|
33
35
|
const x = sampleGamma(alpha);
|
|
34
36
|
const y = sampleGamma(beta);
|
|
35
|
-
if (x + y === 0)
|
|
37
|
+
if (x + y === 0)
|
|
38
|
+
return 0.5;
|
|
36
39
|
return x / (x + y);
|
|
37
40
|
}
|
|
38
41
|
var SIGNAL_INDEX = {
|
|
@@ -150,7 +153,7 @@ var HybridWeightLearner = class {
|
|
|
150
153
|
}
|
|
151
154
|
};
|
|
152
155
|
|
|
153
|
-
// ../chitragupta/packages/smriti/
|
|
156
|
+
// ../chitragupta/packages/smriti/dist/hybrid-search.js
|
|
154
157
|
var PRAMANA_RELIABILITY = {
|
|
155
158
|
pratyaksha: 1,
|
|
156
159
|
anumana: 0.85,
|
|
@@ -194,11 +197,15 @@ function shouldRetrieve(query) {
|
|
|
194
197
|
/\bshow me\b.*\bfrom\b/
|
|
195
198
|
];
|
|
196
199
|
for (const pattern of gapPatterns) {
|
|
197
|
-
if (pattern.test(lower))
|
|
200
|
+
if (pattern.test(lower))
|
|
201
|
+
return true;
|
|
198
202
|
}
|
|
199
|
-
if (lower.endsWith("?") && lower.length > 20)
|
|
200
|
-
|
|
201
|
-
if (
|
|
203
|
+
if (lower.endsWith("?") && lower.length > 20)
|
|
204
|
+
return true;
|
|
205
|
+
if (/session[:\s]/i.test(lower))
|
|
206
|
+
return true;
|
|
207
|
+
if (/\bproject\b.*\b(memory|context|knowledge)\b/i.test(lower))
|
|
208
|
+
return true;
|
|
202
209
|
return false;
|
|
203
210
|
}
|
|
204
211
|
var HybridSearchEngine = class {
|
|
@@ -244,7 +251,8 @@ var HybridSearchEngine = class {
|
|
|
244
251
|
* for each contributing signal (and pramana if present).
|
|
245
252
|
*/
|
|
246
253
|
recordFeedback(result, success) {
|
|
247
|
-
if (!this.weightLearner)
|
|
254
|
+
if (!this.weightLearner)
|
|
255
|
+
return;
|
|
248
256
|
for (const source of result.sources) {
|
|
249
257
|
this.weightLearner.update(source, success);
|
|
250
258
|
}
|
|
@@ -262,64 +270,64 @@ var HybridSearchEngine = class {
|
|
|
262
270
|
const rankings = [];
|
|
263
271
|
const tasks = [];
|
|
264
272
|
if (cfg.enableBM25) {
|
|
265
|
-
tasks.push(
|
|
266
|
-
(
|
|
267
|
-
|
|
273
|
+
tasks.push((async () => {
|
|
274
|
+
const bm25Results = searchSessions(query, cfg.project);
|
|
275
|
+
rankings.push({
|
|
276
|
+
source: "bm25",
|
|
277
|
+
weight: weights.bm25,
|
|
278
|
+
results: bm25Results.map((meta) => ({
|
|
279
|
+
id: meta.id,
|
|
280
|
+
title: meta.title,
|
|
281
|
+
content: `${meta.title} [${meta.tags.join(", ")}] agent:${meta.agent}`,
|
|
282
|
+
timestamp: meta.created ? Date.parse(meta.created) : void 0
|
|
283
|
+
}))
|
|
284
|
+
});
|
|
285
|
+
})());
|
|
286
|
+
}
|
|
287
|
+
if (cfg.enableVector && this.recallEngine) {
|
|
288
|
+
tasks.push((async () => {
|
|
289
|
+
try {
|
|
290
|
+
const vectorResults = await this.recallEngine.recall(query, {
|
|
291
|
+
topK: cfg.topK * 2
|
|
292
|
+
// Over-fetch for fusion
|
|
293
|
+
});
|
|
268
294
|
rankings.push({
|
|
269
|
-
source: "
|
|
270
|
-
weight: weights.
|
|
271
|
-
results:
|
|
272
|
-
id:
|
|
273
|
-
title:
|
|
274
|
-
content:
|
|
295
|
+
source: "vector",
|
|
296
|
+
weight: weights.vector,
|
|
297
|
+
results: vectorResults.map((r) => ({
|
|
298
|
+
id: r.sessionId,
|
|
299
|
+
title: r.title,
|
|
300
|
+
content: r.matchedContent || r.summary
|
|
275
301
|
}))
|
|
276
302
|
});
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
(async () => {
|
|
283
|
-
try {
|
|
284
|
-
const vectorResults = await this.recallEngine.recall(query, {
|
|
285
|
-
topK: cfg.topK * 2
|
|
286
|
-
// Over-fetch for fusion
|
|
287
|
-
});
|
|
288
|
-
rankings.push({
|
|
289
|
-
source: "vector",
|
|
290
|
-
weight: weights.vector,
|
|
291
|
-
results: vectorResults.map((r) => ({
|
|
292
|
-
id: r.sessionId,
|
|
293
|
-
title: r.title,
|
|
294
|
-
content: r.matchedContent || r.summary
|
|
295
|
-
}))
|
|
296
|
-
});
|
|
297
|
-
} catch {
|
|
298
|
-
}
|
|
299
|
-
})()
|
|
300
|
-
);
|
|
303
|
+
} catch (err) {
|
|
304
|
+
process.stderr.write(`[smriti:hybrid-search] vector search failed: ${err instanceof Error ? err.message : String(err)}
|
|
305
|
+
`);
|
|
306
|
+
}
|
|
307
|
+
})());
|
|
301
308
|
}
|
|
302
309
|
if (cfg.enableGraphRAG && this.graphEngine) {
|
|
303
|
-
tasks.push(
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
}
|
|
319
|
-
);
|
|
310
|
+
tasks.push((async () => {
|
|
311
|
+
try {
|
|
312
|
+
const graphResults = await this.graphEngine.search(query, void 0, cfg.topK * 2);
|
|
313
|
+
rankings.push({
|
|
314
|
+
source: "graphrag",
|
|
315
|
+
weight: weights.graphrag,
|
|
316
|
+
results: graphResults.map((node) => ({
|
|
317
|
+
id: node.id,
|
|
318
|
+
title: node.label,
|
|
319
|
+
content: node.content
|
|
320
|
+
}))
|
|
321
|
+
});
|
|
322
|
+
} catch (err) {
|
|
323
|
+
process.stderr.write(`[smriti:hybrid-search] graphRAG search failed: ${err instanceof Error ? err.message : String(err)}
|
|
324
|
+
`);
|
|
325
|
+
}
|
|
326
|
+
})());
|
|
320
327
|
}
|
|
321
328
|
await Promise.all(tasks);
|
|
322
|
-
if (rankings.length === 0)
|
|
329
|
+
if (rankings.length === 0)
|
|
330
|
+
return [];
|
|
323
331
|
const fusedScores = /* @__PURE__ */ new Map();
|
|
324
332
|
for (const ranking of rankings) {
|
|
325
333
|
for (let rank = 0; rank < ranking.results.length; rank++) {
|
|
@@ -333,6 +341,9 @@ var HybridSearchEngine = class {
|
|
|
333
341
|
if (doc.content.length > existing.content.length) {
|
|
334
342
|
existing.content = doc.content;
|
|
335
343
|
}
|
|
344
|
+
if (existing.timestamp === void 0 && doc.timestamp !== void 0) {
|
|
345
|
+
existing.timestamp = doc.timestamp;
|
|
346
|
+
}
|
|
336
347
|
} else {
|
|
337
348
|
const sources = /* @__PURE__ */ new Set();
|
|
338
349
|
sources.add(ranking.source);
|
|
@@ -342,7 +353,8 @@ var HybridSearchEngine = class {
|
|
|
342
353
|
content: doc.content,
|
|
343
354
|
score: rrfContribution,
|
|
344
355
|
sources,
|
|
345
|
-
ranks: { [ranking.source]: rank + 1 }
|
|
356
|
+
ranks: { [ranking.source]: rank + 1 },
|
|
357
|
+
timestamp: doc.timestamp
|
|
346
358
|
});
|
|
347
359
|
}
|
|
348
360
|
}
|
|
@@ -393,7 +405,8 @@ var HybridSearchEngine = class {
|
|
|
393
405
|
}
|
|
394
406
|
/** Self-RAG gated search -- only retrieves if the query signals a knowledge gap. */
|
|
395
407
|
async gatedSearch(query, configOverride) {
|
|
396
|
-
if (!shouldRetrieve(query))
|
|
408
|
+
if (!shouldRetrieve(query))
|
|
409
|
+
return [];
|
|
397
410
|
return this.search(query, configOverride);
|
|
398
411
|
}
|
|
399
412
|
};
|
|
@@ -404,4 +417,4 @@ export {
|
|
|
404
417
|
shouldRetrieve,
|
|
405
418
|
HybridSearchEngine
|
|
406
419
|
};
|
|
407
|
-
//# sourceMappingURL=chunk-
|
|
420
|
+
//# sourceMappingURL=chunk-HXHDP2PZ.js.map
|