@yugenlab/vaayu 0.1.9 → 0.1.11
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-O3NUV7KG.js} +1 -1
- package/chunks/{chunk-UZ6OIVEC.js → chunk-2OBLQJYJ.js} +1 -1
- package/chunks/{chunk-PJEYJQ2C.js → chunk-3AYSJ7WB.js} +30 -18
- package/chunks/{chunk-U62ABYKD.js → chunk-67DXWEKG.js} +3 -3
- package/chunks/{chunk-6556EKOB.js → chunk-7AYYXHYZ.js} +25 -24
- package/chunks/{chunk-IGBRBFXX.js → chunk-7XV5ISV7.js} +7 -5
- package/chunks/{chunk-JAWZ7ANC.js → chunk-A3HOZBC5.js} +11 -7
- package/chunks/{chunk-LVE2EOOH.js → chunk-D46QTN3G.js} +126 -136
- package/chunks/{chunk-PRXQW76U.js → chunk-EG37M4QL.js} +17 -6
- package/chunks/{chunk-7UOXFHEB.js → chunk-F6RNEGFX.js} +480 -432
- package/chunks/{chunk-MJ74G5RB.js → chunk-G2QREGXK.js} +2 -2
- package/chunks/{chunk-DOQMEQ5S.js → chunk-JZTFJE7M.js} +39 -39
- package/chunks/{chunk-S2HDNNC7.js → chunk-LJUEMPLG.js} +638 -679
- package/chunks/{chunk-C76USAC5.js → chunk-QFGAB4XD.js} +13 -5
- package/chunks/{chunk-D3RVJGO7.js → chunk-QV4GPIPT.js} +118 -135
- package/chunks/{chunk-YJRXLRTE.js → chunk-V2ZIKDN4.js} +9 -8
- package/chunks/{chunk-YSC77CKZ.js → chunk-VCUJES75.js} +3276 -3526
- package/chunks/{chunk-OBYBBGHA.js → chunk-W4PVGBUH.js} +190 -189
- package/chunks/chunk-Z576WVLG.js +434 -0
- package/chunks/{chunk-NHRBVSN3.js → chunk-ZYY6N3SP.js} +117 -110
- package/chunks/{consolidation-indexer-CD6DS2HO.js → consolidation-indexer-VIWOP6VO.js} +8 -8
- package/chunks/{day-consolidation-U3X6P4ZG.js → day-consolidation-HMHSXIOM.js} +8 -4
- package/chunks/{src-ZAKUL232.js → dist-CY5NX2IK.js} +17 -17
- package/chunks/graphrag-T2QWNX57.js +14 -0
- package/chunks/{hierarchical-temporal-search-ETXYYJZK.js → hierarchical-temporal-search-U6DG74IR.js} +2 -2
- package/chunks/hybrid-search-BYTXCOXP.js +20 -0
- package/chunks/{memory-store-A6WOWLWC.js → memory-store-LEERUQGL.js} +3 -3
- package/chunks/periodic-consolidation-D6SSKZ7H.js +11 -0
- package/chunks/{postgres-WLH3D5HG.js → postgres-7GZDDX77.js} +2 -2
- package/chunks/{recall-IUPQCBYP.js → recall-LNRQVATQ.js} +7 -7
- package/chunks/search-BIODUW2P.js +19 -0
- package/chunks/{session-store-NDUDYAC7.js → session-store-O3TS7DUY.js} +5 -5
- package/chunks/{sqlite-DHUQGPR5.js → sqlite-7BC4DJTN.js} +2 -2
- package/chunks/vasana-engine-BJFHJVGM.js +30 -0
- package/gateway.js +31671 -24786
- package/package.json +1 -1
- package/pair-cli.js +1 -1
- package/chunks/chunk-TEQKXGIK.js +0 -752
- package/chunks/graphrag-LAZSXLLI.js +0 -14
- package/chunks/hybrid-search-TX6T3KYH.js +0 -20
- package/chunks/periodic-consolidation-4MACZE6S.js +0 -11
- package/chunks/search-HHSVHBXC.js +0 -19
- package/chunks/vasana-engine-G6BPOFX7.js +0 -10
|
@@ -450,6 +450,10 @@ var createSessionStore = (pool) => {
|
|
|
450
450
|
event.createdAt
|
|
451
451
|
]
|
|
452
452
|
);
|
|
453
|
+
await pool.query(
|
|
454
|
+
"UPDATE sessions SET updated_at = $1 WHERE id = $2",
|
|
455
|
+
[event.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(), event.sessionId]
|
|
456
|
+
);
|
|
453
457
|
},
|
|
454
458
|
async listSessionEvents(sessionId, options) {
|
|
455
459
|
const limit = options?.limit ?? 50;
|
|
@@ -503,10 +507,14 @@ var createSessionPrefsStore = (pool) => {
|
|
|
503
507
|
async setSessionPrefs(sessionId, prefs) {
|
|
504
508
|
const existing = await this.getSessionPrefs(sessionId);
|
|
505
509
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
506
|
-
const
|
|
507
|
-
const
|
|
508
|
-
const
|
|
509
|
-
const
|
|
510
|
+
const hasProviderId = Object.prototype.hasOwnProperty.call(prefs, "providerId");
|
|
511
|
+
const providerId = hasProviderId ? prefs.providerId ?? null : existing?.providerId ?? null;
|
|
512
|
+
const hasModel = Object.prototype.hasOwnProperty.call(prefs, "model");
|
|
513
|
+
const model = hasModel ? prefs.model ?? null : existing?.model ?? null;
|
|
514
|
+
const hasSystem = Object.prototype.hasOwnProperty.call(prefs, "system");
|
|
515
|
+
const system = hasSystem ? prefs.system ?? null : existing?.system ?? null;
|
|
516
|
+
const hasAutoRouting = Object.prototype.hasOwnProperty.call(prefs, "autoRouting");
|
|
517
|
+
const autoRouting = hasAutoRouting ? prefs.autoRouting ?? null : existing?.autoRouting ?? null;
|
|
510
518
|
const hasLanguage = Object.prototype.hasOwnProperty.call(prefs, "language");
|
|
511
519
|
const language = hasLanguage ? prefs.language ?? null : existing?.language ?? null;
|
|
512
520
|
const hasLanguageUpdatedAt = Object.prototype.hasOwnProperty.call(prefs, "languageUpdatedAt");
|
|
@@ -1500,4 +1508,4 @@ var PostgresStorage = class _PostgresStorage {
|
|
|
1500
1508
|
export {
|
|
1501
1509
|
PostgresStorage
|
|
1502
1510
|
};
|
|
1503
|
-
//# sourceMappingURL=chunk-
|
|
1511
|
+
//# sourceMappingURL=chunk-QFGAB4XD.js.map
|
|
@@ -1,26 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
searchSessions
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-3AYSJ7WB.js";
|
|
4
4
|
|
|
5
|
-
// ../chitragupta/packages/smriti/
|
|
6
|
-
var PRAMANA_RELIABILITY = {
|
|
7
|
-
pratyaksha: 1,
|
|
8
|
-
anumana: 0.85,
|
|
9
|
-
shabda: 0.75,
|
|
10
|
-
upamana: 0.6,
|
|
11
|
-
arthapatti: 0.5,
|
|
12
|
-
anupalabdhi: 0.4
|
|
13
|
-
};
|
|
14
|
-
var DEFAULT_CONFIG = {
|
|
15
|
-
k: 60,
|
|
16
|
-
topK: 10,
|
|
17
|
-
enableBM25: true,
|
|
18
|
-
enableVector: true,
|
|
19
|
-
enableGraphRAG: true,
|
|
20
|
-
pramanaWeight: 0.1,
|
|
21
|
-
enablePramana: true,
|
|
22
|
-
minScore: 0
|
|
23
|
-
};
|
|
5
|
+
// ../chitragupta/packages/smriti/dist/hybrid-search-learner.js
|
|
24
6
|
function gaussianRandom() {
|
|
25
7
|
const u1 = Math.random();
|
|
26
8
|
const u2 = Math.random();
|
|
@@ -43,14 +25,17 @@ function sampleGamma(shape) {
|
|
|
43
25
|
v = v * v * v;
|
|
44
26
|
const u = Math.random();
|
|
45
27
|
const zSq = z * z;
|
|
46
|
-
if (u < 1 - 0.0331 * (zSq * zSq))
|
|
47
|
-
|
|
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;
|
|
48
32
|
}
|
|
49
33
|
}
|
|
50
34
|
function sampleBeta(alpha, beta) {
|
|
51
35
|
const x = sampleGamma(alpha);
|
|
52
36
|
const y = sampleGamma(beta);
|
|
53
|
-
if (x + y === 0)
|
|
37
|
+
if (x + y === 0)
|
|
38
|
+
return 0.5;
|
|
54
39
|
return x / (x + y);
|
|
55
40
|
}
|
|
56
41
|
var SIGNAL_INDEX = {
|
|
@@ -61,15 +46,17 @@ var SIGNAL_INDEX = {
|
|
|
61
46
|
};
|
|
62
47
|
var NUM_SIGNALS = 4;
|
|
63
48
|
var HybridWeightLearner = class {
|
|
64
|
-
/** Success counts (
|
|
49
|
+
/** Success counts (alpha) for each of the 4 signals. */
|
|
65
50
|
_alphas;
|
|
66
|
-
/** Failure counts (
|
|
51
|
+
/** Failure counts (beta) for each of the 4 signals. */
|
|
67
52
|
_betas;
|
|
68
53
|
/** Total feedback events received. */
|
|
69
54
|
_totalFeedback;
|
|
70
55
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
56
|
+
* Create a new weight learner with the given prior.
|
|
57
|
+
*
|
|
58
|
+
* @param priorAlpha - Initial alpha for all signals. Default: 1 (uniform prior).
|
|
59
|
+
* @param priorBeta - Initial beta for all signals. Default: 1 (uniform prior).
|
|
73
60
|
*/
|
|
74
61
|
constructor(priorAlpha = 1, priorBeta = 1) {
|
|
75
62
|
this._alphas = new Float64Array(NUM_SIGNALS);
|
|
@@ -83,7 +70,7 @@ var HybridWeightLearner = class {
|
|
|
83
70
|
/**
|
|
84
71
|
* Sample a weight vector from the Beta posteriors.
|
|
85
72
|
*
|
|
86
|
-
* Each signal's weight is sampled from Beta(
|
|
73
|
+
* Each signal's weight is sampled from Beta(alpha_i, beta_i), then the 4
|
|
87
74
|
* weights are normalized to sum to 1 (Dirichlet-like normalization).
|
|
88
75
|
*
|
|
89
76
|
* @returns Normalized weight vector { bm25, vector, graphrag, pramana }.
|
|
@@ -122,8 +109,10 @@ var HybridWeightLearner = class {
|
|
|
122
109
|
this._totalFeedback += 1;
|
|
123
110
|
}
|
|
124
111
|
/**
|
|
125
|
-
* Get the posterior mean for each signal:
|
|
112
|
+
* Get the posterior mean for each signal: alpha / (alpha + beta).
|
|
126
113
|
* Useful for diagnostics and logging.
|
|
114
|
+
*
|
|
115
|
+
* @returns Posterior mean for each of the 4 signals.
|
|
127
116
|
*/
|
|
128
117
|
means() {
|
|
129
118
|
const m = (i) => this._alphas[i] / (this._alphas[i] + this._betas[i]);
|
|
@@ -148,6 +137,8 @@ var HybridWeightLearner = class {
|
|
|
148
137
|
/**
|
|
149
138
|
* Restore the learner state from a serialized object.
|
|
150
139
|
*
|
|
140
|
+
* Silently ignores invalid data to avoid corrupting the current state.
|
|
141
|
+
*
|
|
151
142
|
* @param data - Previously serialized state from `serialize()`.
|
|
152
143
|
*/
|
|
153
144
|
restore(data) {
|
|
@@ -161,6 +152,26 @@ var HybridWeightLearner = class {
|
|
|
161
152
|
this._totalFeedback = data.totalFeedback ?? 0;
|
|
162
153
|
}
|
|
163
154
|
};
|
|
155
|
+
|
|
156
|
+
// ../chitragupta/packages/smriti/dist/hybrid-search.js
|
|
157
|
+
var PRAMANA_RELIABILITY = {
|
|
158
|
+
pratyaksha: 1,
|
|
159
|
+
anumana: 0.85,
|
|
160
|
+
shabda: 0.75,
|
|
161
|
+
upamana: 0.6,
|
|
162
|
+
arthapatti: 0.5,
|
|
163
|
+
anupalabdhi: 0.4
|
|
164
|
+
};
|
|
165
|
+
var DEFAULT_CONFIG = {
|
|
166
|
+
k: 60,
|
|
167
|
+
topK: 10,
|
|
168
|
+
enableBM25: true,
|
|
169
|
+
enableVector: true,
|
|
170
|
+
enableGraphRAG: true,
|
|
171
|
+
pramanaWeight: 0.1,
|
|
172
|
+
enablePramana: true,
|
|
173
|
+
minScore: 0
|
|
174
|
+
};
|
|
164
175
|
function shouldRetrieve(query) {
|
|
165
176
|
const lower = query.toLowerCase().trim();
|
|
166
177
|
const gapPatterns = [
|
|
@@ -186,11 +197,15 @@ function shouldRetrieve(query) {
|
|
|
186
197
|
/\bshow me\b.*\bfrom\b/
|
|
187
198
|
];
|
|
188
199
|
for (const pattern of gapPatterns) {
|
|
189
|
-
if (pattern.test(lower))
|
|
200
|
+
if (pattern.test(lower))
|
|
201
|
+
return true;
|
|
190
202
|
}
|
|
191
|
-
if (lower.endsWith("?") && lower.length > 20)
|
|
192
|
-
|
|
193
|
-
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;
|
|
194
209
|
return false;
|
|
195
210
|
}
|
|
196
211
|
var HybridSearchEngine = class {
|
|
@@ -199,6 +214,7 @@ var HybridSearchEngine = class {
|
|
|
199
214
|
config;
|
|
200
215
|
weightLearner;
|
|
201
216
|
kalaChakra;
|
|
217
|
+
/** Create a new hybrid search engine with optional engines and learner. */
|
|
202
218
|
constructor(config, recallEngine, graphEngine, weightLearner) {
|
|
203
219
|
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
204
220
|
this.recallEngine = recallEngine ?? null;
|
|
@@ -206,54 +222,37 @@ var HybridSearchEngine = class {
|
|
|
206
222
|
this.weightLearner = weightLearner ?? null;
|
|
207
223
|
this.kalaChakra = null;
|
|
208
224
|
}
|
|
209
|
-
/**
|
|
210
|
-
* Set or replace the RecallEngine instance.
|
|
211
|
-
*/
|
|
225
|
+
/** Set or replace the RecallEngine instance. */
|
|
212
226
|
setRecallEngine(engine) {
|
|
213
227
|
this.recallEngine = engine;
|
|
214
228
|
}
|
|
215
|
-
/**
|
|
216
|
-
* Set or replace the GraphRAGEngine instance.
|
|
217
|
-
*/
|
|
229
|
+
/** Set or replace the GraphRAGEngine instance. */
|
|
218
230
|
setGraphEngine(engine) {
|
|
219
231
|
this.graphEngine = engine;
|
|
220
232
|
}
|
|
221
|
-
/**
|
|
222
|
-
* Set or replace the HybridWeightLearner instance.
|
|
223
|
-
*/
|
|
233
|
+
/** Set or replace the HybridWeightLearner instance. */
|
|
224
234
|
setWeightLearner(learner) {
|
|
225
235
|
this.weightLearner = learner;
|
|
226
236
|
}
|
|
227
|
-
/**
|
|
228
|
-
* Get the current HybridWeightLearner, or null if not set.
|
|
229
|
-
*/
|
|
237
|
+
/** Get the current HybridWeightLearner, or null if not set. */
|
|
230
238
|
getWeightLearner() {
|
|
231
239
|
return this.weightLearner;
|
|
232
240
|
}
|
|
233
|
-
/**
|
|
234
|
-
* Set or replace the KalaChakra temporal awareness engine.
|
|
235
|
-
* When set, search results with timestamps receive a temporal boost.
|
|
236
|
-
*/
|
|
241
|
+
/** Set or replace the KalaChakra temporal awareness engine. */
|
|
237
242
|
setKalaChakra(kala) {
|
|
238
243
|
this.kalaChakra = kala;
|
|
239
244
|
}
|
|
240
|
-
/**
|
|
241
|
-
* Get the current KalaChakra instance, or null if not set.
|
|
242
|
-
*/
|
|
245
|
+
/** Get the current KalaChakra instance, or null if not set. */
|
|
243
246
|
getKalaChakra() {
|
|
244
247
|
return this.kalaChakra;
|
|
245
248
|
}
|
|
246
249
|
/**
|
|
247
|
-
* Record feedback for a search result.
|
|
248
|
-
*
|
|
249
|
-
* Updates the Thompson Sampling weight learner based on which signals
|
|
250
|
-
* contributed to the result the user selected (success) or rejected (failure).
|
|
251
|
-
*
|
|
252
|
-
* @param result - The search result receiving feedback.
|
|
253
|
-
* @param success - true = user found it useful, false = irrelevant.
|
|
250
|
+
* Record feedback for a search result. Updates Thompson Sampling posteriors
|
|
251
|
+
* for each contributing signal (and pramana if present).
|
|
254
252
|
*/
|
|
255
253
|
recordFeedback(result, success) {
|
|
256
|
-
if (!this.weightLearner)
|
|
254
|
+
if (!this.weightLearner)
|
|
255
|
+
return;
|
|
257
256
|
for (const source of result.sources) {
|
|
258
257
|
this.weightLearner.update(source, success);
|
|
259
258
|
}
|
|
@@ -262,20 +261,8 @@ var HybridSearchEngine = class {
|
|
|
262
261
|
}
|
|
263
262
|
}
|
|
264
263
|
/**
|
|
265
|
-
* Perform hybrid search across all enabled rankers.
|
|
266
|
-
*
|
|
267
|
-
* Each ranker produces its own ranking. Results are fused via RRF:
|
|
268
|
-
* score(d) = Σ w_i / (k + rank_i(d))
|
|
269
|
-
*
|
|
270
|
-
* When a HybridWeightLearner is set, w_i are Thompson-sampled weights.
|
|
271
|
-
* Otherwise, all weights are 1.0 (standard RRF).
|
|
272
|
-
*
|
|
273
|
-
* When pramana is enabled, each result receives an additive epistemic boost:
|
|
274
|
-
* finalScore += δ * pramanaReliability(d)
|
|
275
|
-
*
|
|
276
|
-
* @param query - The search query.
|
|
277
|
-
* @param configOverride - Optional per-query config overrides.
|
|
278
|
-
* @returns Fused results sorted by score descending.
|
|
264
|
+
* Perform hybrid search across all enabled rankers, fusing via weighted RRF.
|
|
265
|
+
* When a HybridWeightLearner is set, weights are Thompson-sampled; otherwise uniform.
|
|
279
266
|
*/
|
|
280
267
|
async search(query, configOverride) {
|
|
281
268
|
const cfg = { ...this.config, ...configOverride };
|
|
@@ -283,64 +270,60 @@ var HybridSearchEngine = class {
|
|
|
283
270
|
const rankings = [];
|
|
284
271
|
const tasks = [];
|
|
285
272
|
if (cfg.enableBM25) {
|
|
286
|
-
tasks.push(
|
|
287
|
-
(
|
|
288
|
-
|
|
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
|
+
});
|
|
289
294
|
rankings.push({
|
|
290
|
-
source: "
|
|
291
|
-
weight: weights.
|
|
292
|
-
results:
|
|
293
|
-
id:
|
|
294
|
-
title:
|
|
295
|
-
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
|
|
296
301
|
}))
|
|
297
302
|
});
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
if (cfg.enableVector && this.recallEngine) {
|
|
302
|
-
tasks.push(
|
|
303
|
-
(async () => {
|
|
304
|
-
try {
|
|
305
|
-
const vectorResults = await this.recallEngine.recall(query, {
|
|
306
|
-
topK: cfg.topK * 2
|
|
307
|
-
// Over-fetch for fusion
|
|
308
|
-
});
|
|
309
|
-
rankings.push({
|
|
310
|
-
source: "vector",
|
|
311
|
-
weight: weights.vector,
|
|
312
|
-
results: vectorResults.map((r) => ({
|
|
313
|
-
id: r.sessionId,
|
|
314
|
-
title: r.title,
|
|
315
|
-
content: r.matchedContent || r.summary
|
|
316
|
-
}))
|
|
317
|
-
});
|
|
318
|
-
} catch {
|
|
319
|
-
}
|
|
320
|
-
})()
|
|
321
|
-
);
|
|
303
|
+
} catch {
|
|
304
|
+
}
|
|
305
|
+
})());
|
|
322
306
|
}
|
|
323
307
|
if (cfg.enableGraphRAG && this.graphEngine) {
|
|
324
|
-
tasks.push(
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
})()
|
|
340
|
-
);
|
|
308
|
+
tasks.push((async () => {
|
|
309
|
+
try {
|
|
310
|
+
const graphResults = await this.graphEngine.search(query, void 0, cfg.topK * 2);
|
|
311
|
+
rankings.push({
|
|
312
|
+
source: "graphrag",
|
|
313
|
+
weight: weights.graphrag,
|
|
314
|
+
results: graphResults.map((node) => ({
|
|
315
|
+
id: node.id,
|
|
316
|
+
title: node.label,
|
|
317
|
+
content: node.content
|
|
318
|
+
}))
|
|
319
|
+
});
|
|
320
|
+
} catch {
|
|
321
|
+
}
|
|
322
|
+
})());
|
|
341
323
|
}
|
|
342
324
|
await Promise.all(tasks);
|
|
343
|
-
if (rankings.length === 0)
|
|
325
|
+
if (rankings.length === 0)
|
|
326
|
+
return [];
|
|
344
327
|
const fusedScores = /* @__PURE__ */ new Map();
|
|
345
328
|
for (const ranking of rankings) {
|
|
346
329
|
for (let rank = 0; rank < ranking.results.length; rank++) {
|
|
@@ -354,6 +337,9 @@ var HybridSearchEngine = class {
|
|
|
354
337
|
if (doc.content.length > existing.content.length) {
|
|
355
338
|
existing.content = doc.content;
|
|
356
339
|
}
|
|
340
|
+
if (existing.timestamp === void 0 && doc.timestamp !== void 0) {
|
|
341
|
+
existing.timestamp = doc.timestamp;
|
|
342
|
+
}
|
|
357
343
|
} else {
|
|
358
344
|
const sources = /* @__PURE__ */ new Set();
|
|
359
345
|
sources.add(ranking.source);
|
|
@@ -363,7 +349,8 @@ var HybridSearchEngine = class {
|
|
|
363
349
|
content: doc.content,
|
|
364
350
|
score: rrfContribution,
|
|
365
351
|
sources,
|
|
366
|
-
ranks: { [ranking.source]: rank + 1 }
|
|
352
|
+
ranks: { [ranking.source]: rank + 1 },
|
|
353
|
+
timestamp: doc.timestamp
|
|
367
354
|
});
|
|
368
355
|
}
|
|
369
356
|
}
|
|
@@ -412,22 +399,18 @@ var HybridSearchEngine = class {
|
|
|
412
399
|
timestamp: r.timestamp
|
|
413
400
|
}));
|
|
414
401
|
}
|
|
415
|
-
/**
|
|
416
|
-
* Self-RAG gated search — only retrieves if the query signals a knowledge gap.
|
|
417
|
-
*
|
|
418
|
-
* @param query - The query to evaluate and optionally search.
|
|
419
|
-
* @returns Results if retrieval was triggered, empty array otherwise.
|
|
420
|
-
*/
|
|
402
|
+
/** Self-RAG gated search -- only retrieves if the query signals a knowledge gap. */
|
|
421
403
|
async gatedSearch(query, configOverride) {
|
|
422
|
-
if (!shouldRetrieve(query))
|
|
404
|
+
if (!shouldRetrieve(query))
|
|
405
|
+
return [];
|
|
423
406
|
return this.search(query, configOverride);
|
|
424
407
|
}
|
|
425
408
|
};
|
|
426
409
|
|
|
427
410
|
export {
|
|
428
|
-
PRAMANA_RELIABILITY,
|
|
429
411
|
HybridWeightLearner,
|
|
412
|
+
PRAMANA_RELIABILITY,
|
|
430
413
|
shouldRetrieve,
|
|
431
414
|
HybridSearchEngine
|
|
432
415
|
};
|
|
433
|
-
//# sourceMappingURL=chunk-
|
|
416
|
+
//# sourceMappingURL=chunk-QV4GPIPT.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ../chitragupta/packages/smriti/
|
|
1
|
+
// ../chitragupta/packages/smriti/dist/db/schema.js
|
|
2
2
|
var AGENT_SCHEMA_VERSION = 4;
|
|
3
3
|
var GRAPH_SCHEMA_VERSION = 1;
|
|
4
4
|
var VECTORS_SCHEMA_VERSION = 1;
|
|
@@ -10,7 +10,8 @@ function initAllSchemas(dbm) {
|
|
|
10
10
|
function initAgentSchema(dbm) {
|
|
11
11
|
const db = dbm.get("agent");
|
|
12
12
|
const currentVersion = getSchemaVersion(db, "agent");
|
|
13
|
-
if (currentVersion >= AGENT_SCHEMA_VERSION)
|
|
13
|
+
if (currentVersion >= AGENT_SCHEMA_VERSION)
|
|
14
|
+
return;
|
|
14
15
|
db.exec(`
|
|
15
16
|
-- \u2500\u2500\u2500 Sessions \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
16
17
|
CREATE TABLE IF NOT EXISTS sessions (
|
|
@@ -243,7 +244,8 @@ function initAgentSchema(dbm) {
|
|
|
243
244
|
function initGraphSchema(dbm) {
|
|
244
245
|
const db = dbm.get("graph");
|
|
245
246
|
const currentVersion = getSchemaVersion(db, "graph");
|
|
246
|
-
if (currentVersion >= GRAPH_SCHEMA_VERSION)
|
|
247
|
+
if (currentVersion >= GRAPH_SCHEMA_VERSION)
|
|
248
|
+
return;
|
|
247
249
|
db.exec(`
|
|
248
250
|
-- \u2500\u2500\u2500 Nodes \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
249
251
|
CREATE TABLE IF NOT EXISTS nodes (
|
|
@@ -290,7 +292,8 @@ function initGraphSchema(dbm) {
|
|
|
290
292
|
function initVectorsSchema(dbm) {
|
|
291
293
|
const db = dbm.get("vectors");
|
|
292
294
|
const currentVersion = getSchemaVersion(db, "vectors");
|
|
293
|
-
if (currentVersion >= VECTORS_SCHEMA_VERSION)
|
|
295
|
+
if (currentVersion >= VECTORS_SCHEMA_VERSION)
|
|
296
|
+
return;
|
|
294
297
|
db.exec(`
|
|
295
298
|
-- \u2500\u2500\u2500 Embeddings \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
296
299
|
CREATE TABLE IF NOT EXISTS embeddings (
|
|
@@ -323,9 +326,7 @@ function getSchemaVersion(db, name) {
|
|
|
323
326
|
}
|
|
324
327
|
function setSchemaVersion(db, name, version) {
|
|
325
328
|
ensureVersionTable(db);
|
|
326
|
-
db.prepare(
|
|
327
|
-
"INSERT OR REPLACE INTO _schema_versions (name, version) VALUES (?, ?)"
|
|
328
|
-
).run(name, version);
|
|
329
|
+
db.prepare("INSERT OR REPLACE INTO _schema_versions (name, version) VALUES (?, ?)").run(name, version);
|
|
329
330
|
}
|
|
330
331
|
|
|
331
332
|
export {
|
|
@@ -334,4 +335,4 @@ export {
|
|
|
334
335
|
initGraphSchema,
|
|
335
336
|
initVectorsSchema
|
|
336
337
|
};
|
|
337
|
-
//# sourceMappingURL=chunk-
|
|
338
|
+
//# sourceMappingURL=chunk-V2ZIKDN4.js.map
|