@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,26 +1,34 @@
|
|
|
1
1
|
import {
|
|
2
|
+
init_session_store,
|
|
2
3
|
listSessions,
|
|
3
4
|
loadSession
|
|
4
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-FEDPZOZ5.js";
|
|
5
6
|
import {
|
|
6
7
|
EmbeddingService,
|
|
7
8
|
cosineSimilarity,
|
|
8
9
|
estimateTokens
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-RVKTGKFD.js";
|
|
10
11
|
import {
|
|
11
|
-
initVectorsSchema
|
|
12
|
-
|
|
12
|
+
initVectorsSchema,
|
|
13
|
+
init_schema
|
|
14
|
+
} from "./chunk-VEZ2DI2M.js";
|
|
13
15
|
import {
|
|
14
|
-
DatabaseManager
|
|
15
|
-
|
|
16
|
+
DatabaseManager,
|
|
17
|
+
init_database
|
|
18
|
+
} from "./chunk-H46F2Y6R.js";
|
|
16
19
|
import {
|
|
17
|
-
getChitraguptaHome
|
|
18
|
-
|
|
20
|
+
getChitraguptaHome,
|
|
21
|
+
init_dist
|
|
22
|
+
} from "./chunk-KVQH4LE7.js";
|
|
19
23
|
|
|
20
|
-
// ../chitragupta/packages/smriti/
|
|
24
|
+
// ../chitragupta/packages/smriti/dist/recall.js
|
|
25
|
+
init_database();
|
|
26
|
+
init_schema();
|
|
27
|
+
init_session_store();
|
|
21
28
|
import fs3 from "fs";
|
|
22
29
|
|
|
23
|
-
// ../chitragupta/packages/smriti/
|
|
30
|
+
// ../chitragupta/packages/smriti/dist/streams.js
|
|
31
|
+
init_dist();
|
|
24
32
|
import fs from "fs";
|
|
25
33
|
import path from "path";
|
|
26
34
|
var STREAM_CONFIGS = {
|
|
@@ -50,9 +58,7 @@ var STREAM_CONFIGS = {
|
|
|
50
58
|
}
|
|
51
59
|
};
|
|
52
60
|
var STREAM_ORDER = ["identity", "projects", "tasks", "flow"];
|
|
53
|
-
var PRESERVATION_RATIOS = STREAM_ORDER.map(
|
|
54
|
-
(s) => STREAM_CONFIGS[s].preservation
|
|
55
|
-
);
|
|
61
|
+
var PRESERVATION_RATIOS = STREAM_ORDER.map((s) => STREAM_CONFIGS[s].preservation);
|
|
56
62
|
function getStreamsRoot() {
|
|
57
63
|
return path.join(getChitraguptaHome(), "smriti", "streams");
|
|
58
64
|
}
|
|
@@ -166,7 +172,8 @@ var StreamManager = class {
|
|
|
166
172
|
*/
|
|
167
173
|
readContent(streamType, deviceId) {
|
|
168
174
|
const raw = this.read(streamType, deviceId);
|
|
169
|
-
if (!raw)
|
|
175
|
+
if (!raw)
|
|
176
|
+
return "";
|
|
170
177
|
const { content } = parseStreamFile(raw);
|
|
171
178
|
return content;
|
|
172
179
|
}
|
|
@@ -240,10 +247,7 @@ ${entry}`;
|
|
|
240
247
|
* than ephemeral streams (flow).
|
|
241
248
|
*/
|
|
242
249
|
getStreamBudgets(totalBudget) {
|
|
243
|
-
const totalPreservation = STREAM_ORDER.reduce(
|
|
244
|
-
(sum, s) => sum + STREAM_CONFIGS[s].preservation,
|
|
245
|
-
0
|
|
246
|
-
);
|
|
250
|
+
const totalPreservation = STREAM_ORDER.reduce((sum, s) => sum + STREAM_CONFIGS[s].preservation, 0);
|
|
247
251
|
const budgets = {};
|
|
248
252
|
for (const stream of STREAM_ORDER) {
|
|
249
253
|
const ratio = STREAM_CONFIGS[stream].preservation / totalPreservation;
|
|
@@ -268,9 +272,11 @@ ${entry}`;
|
|
|
268
272
|
*/
|
|
269
273
|
enforcePreservation(streamType, maxTokens, deviceId) {
|
|
270
274
|
const raw = this.read(streamType, deviceId);
|
|
271
|
-
if (!raw)
|
|
275
|
+
if (!raw)
|
|
276
|
+
return 0;
|
|
272
277
|
const currentTokens = estimateTokens(raw);
|
|
273
|
-
if (currentTokens <= maxTokens)
|
|
278
|
+
if (currentTokens <= maxTokens)
|
|
279
|
+
return 0;
|
|
274
280
|
const { content } = parseStreamFile(raw);
|
|
275
281
|
const ENTRY_SEP = /(\n\n\*\d{4}-)/;
|
|
276
282
|
const parts = content.split(ENTRY_SEP);
|
|
@@ -312,7 +318,8 @@ ${entry}`;
|
|
|
312
318
|
*/
|
|
313
319
|
listFlowDevices() {
|
|
314
320
|
const flowDir = path.join(this.root, "flow");
|
|
315
|
-
if (!fs.existsSync(flowDir))
|
|
321
|
+
if (!fs.existsSync(flowDir))
|
|
322
|
+
return [];
|
|
316
323
|
try {
|
|
317
324
|
return fs.readdirSync(flowDir).filter((f) => f.endsWith(".md")).map((f) => f.replace(/\.md$/, ""));
|
|
318
325
|
} catch {
|
|
@@ -327,7 +334,7 @@ ${entry}`;
|
|
|
327
334
|
}
|
|
328
335
|
};
|
|
329
336
|
|
|
330
|
-
// ../chitragupta/packages/smriti/
|
|
337
|
+
// ../chitragupta/packages/smriti/dist/recall-scoring.js
|
|
331
338
|
var _embeddingService = new EmbeddingService();
|
|
332
339
|
function configureRecallScoring(options) {
|
|
333
340
|
if (options.embeddingService) {
|
|
@@ -343,7 +350,8 @@ function summarizeSession(session) {
|
|
|
343
350
|
if (turn.role === "user") {
|
|
344
351
|
parts.push(turn.content.slice(0, 200));
|
|
345
352
|
}
|
|
346
|
-
if (parts.join(" ").length > 400)
|
|
353
|
+
if (parts.join(" ").length > 400)
|
|
354
|
+
break;
|
|
347
355
|
}
|
|
348
356
|
return parts.join(" | ").slice(0, 500);
|
|
349
357
|
}
|
|
@@ -367,7 +375,10 @@ function resetOllamaAvailability() {
|
|
|
367
375
|
_embeddingService.resetAvailability();
|
|
368
376
|
}
|
|
369
377
|
|
|
370
|
-
// ../chitragupta/packages/smriti/
|
|
378
|
+
// ../chitragupta/packages/smriti/dist/recall-storage.js
|
|
379
|
+
init_dist();
|
|
380
|
+
init_database();
|
|
381
|
+
init_schema();
|
|
371
382
|
import fs2 from "fs";
|
|
372
383
|
import path2 from "path";
|
|
373
384
|
var DEFAULT_TOP_K = 10;
|
|
@@ -383,11 +394,7 @@ function vectorToBlob(vector) {
|
|
|
383
394
|
return Buffer.from(float32.buffer);
|
|
384
395
|
}
|
|
385
396
|
function blobToVector(blob) {
|
|
386
|
-
const float32 = new Float32Array(
|
|
387
|
-
blob.buffer,
|
|
388
|
-
blob.byteOffset,
|
|
389
|
-
blob.byteLength / 4
|
|
390
|
-
);
|
|
397
|
+
const float32 = new Float32Array(blob.buffer, blob.byteOffset, blob.byteLength / 4);
|
|
391
398
|
return Array.from(float32);
|
|
392
399
|
}
|
|
393
400
|
function migrateEmbeddingsJson() {
|
|
@@ -399,7 +406,9 @@ function migrateEmbeddingsJson() {
|
|
|
399
406
|
try {
|
|
400
407
|
const raw = fs2.readFileSync(jsonPath, "utf-8");
|
|
401
408
|
entries = JSON.parse(raw);
|
|
402
|
-
} catch {
|
|
409
|
+
} catch (err) {
|
|
410
|
+
process.stderr.write(`[smriti:recall-storage] embeddings JSON parse failed: ${err instanceof Error ? err.message : String(err)}
|
|
411
|
+
`);
|
|
403
412
|
return { migrated: 0, skipped: 0 };
|
|
404
413
|
}
|
|
405
414
|
if (!entries || entries.length === 0) {
|
|
@@ -418,28 +427,21 @@ function migrateEmbeddingsJson() {
|
|
|
418
427
|
`);
|
|
419
428
|
for (const entry of entries) {
|
|
420
429
|
try {
|
|
421
|
-
const result = insert.run(
|
|
422
|
-
entry.
|
|
423
|
-
|
|
424
|
-
entry.
|
|
425
|
-
entry.
|
|
426
|
-
entry.
|
|
427
|
-
|
|
428
|
-
JSON.stringify({
|
|
429
|
-
title: entry.title,
|
|
430
|
-
summary: entry.summary,
|
|
431
|
-
tags: entry.tags,
|
|
432
|
-
date: entry.date,
|
|
433
|
-
deviceId: entry.deviceId
|
|
434
|
-
}),
|
|
435
|
-
new Date(entry.date).getTime()
|
|
436
|
-
);
|
|
430
|
+
const result = insert.run(entry.id, vectorToBlob(entry.vector), entry.text, entry.source, entry.sourceId, entry.vector.length, JSON.stringify({
|
|
431
|
+
title: entry.title,
|
|
432
|
+
summary: entry.summary,
|
|
433
|
+
tags: entry.tags,
|
|
434
|
+
date: entry.date,
|
|
435
|
+
deviceId: entry.deviceId
|
|
436
|
+
}), new Date(entry.date).getTime());
|
|
437
437
|
if (result.changes > 0) {
|
|
438
438
|
migrated++;
|
|
439
439
|
} else {
|
|
440
440
|
skipped++;
|
|
441
441
|
}
|
|
442
|
-
} catch {
|
|
442
|
+
} catch (err) {
|
|
443
|
+
process.stderr.write(`[smriti:recall-storage] migration insert failed for ${entry.id}: ${err instanceof Error ? err.message : String(err)}
|
|
444
|
+
`);
|
|
443
445
|
skipped++;
|
|
444
446
|
}
|
|
445
447
|
}
|
|
@@ -447,15 +449,19 @@ function migrateEmbeddingsJson() {
|
|
|
447
449
|
txn();
|
|
448
450
|
try {
|
|
449
451
|
fs2.renameSync(jsonPath, jsonPath + ".bak");
|
|
450
|
-
} catch {
|
|
452
|
+
} catch (err) {
|
|
453
|
+
process.stderr.write(`[smriti:recall-storage] JSON backup rename failed: ${err instanceof Error ? err.message : String(err)}
|
|
454
|
+
`);
|
|
451
455
|
}
|
|
452
|
-
} catch {
|
|
456
|
+
} catch (err) {
|
|
457
|
+
process.stderr.write(`[smriti:recall-storage] migration transaction failed: ${err instanceof Error ? err.message : String(err)}
|
|
458
|
+
`);
|
|
453
459
|
return { migrated: 0, skipped: entries.length };
|
|
454
460
|
}
|
|
455
461
|
return { migrated, skipped };
|
|
456
462
|
}
|
|
457
463
|
|
|
458
|
-
// ../chitragupta/packages/smriti/
|
|
464
|
+
// ../chitragupta/packages/smriti/dist/recall.js
|
|
459
465
|
var _dbInitialized = false;
|
|
460
466
|
function _resetRecallDbInit() {
|
|
461
467
|
_dbInitialized = false;
|
|
@@ -505,7 +511,9 @@ var RecallEngine = class {
|
|
|
505
511
|
deviceId: metadata.deviceId
|
|
506
512
|
};
|
|
507
513
|
});
|
|
508
|
-
} catch {
|
|
514
|
+
} catch (err) {
|
|
515
|
+
process.stderr.write(`[smriti:recall] SQLite load failed, trying JSON fallback: ${err instanceof Error ? err.message : String(err)}
|
|
516
|
+
`);
|
|
509
517
|
this.loadIndexJson();
|
|
510
518
|
}
|
|
511
519
|
this.loaded = true;
|
|
@@ -520,26 +528,19 @@ var RecallEngine = class {
|
|
|
520
528
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
521
529
|
`);
|
|
522
530
|
for (const entry of this.entries) {
|
|
523
|
-
insert.run(
|
|
524
|
-
entry.
|
|
525
|
-
|
|
526
|
-
entry.
|
|
527
|
-
entry.
|
|
528
|
-
entry.
|
|
529
|
-
|
|
530
|
-
JSON.stringify({
|
|
531
|
-
title: entry.title,
|
|
532
|
-
summary: entry.summary,
|
|
533
|
-
tags: entry.tags,
|
|
534
|
-
date: entry.date,
|
|
535
|
-
deviceId: entry.deviceId
|
|
536
|
-
}),
|
|
537
|
-
new Date(entry.date).getTime()
|
|
538
|
-
);
|
|
531
|
+
insert.run(entry.id, vectorToBlob(entry.vector), entry.text, entry.source, entry.sourceId, entry.vector.length, JSON.stringify({
|
|
532
|
+
title: entry.title,
|
|
533
|
+
summary: entry.summary,
|
|
534
|
+
tags: entry.tags,
|
|
535
|
+
date: entry.date,
|
|
536
|
+
deviceId: entry.deviceId
|
|
537
|
+
}), new Date(entry.date).getTime());
|
|
539
538
|
}
|
|
540
539
|
});
|
|
541
540
|
txn();
|
|
542
|
-
} catch {
|
|
541
|
+
} catch (err) {
|
|
542
|
+
process.stderr.write(`[smriti:recall] SQLite save failed, using JSON fallback: ${err instanceof Error ? err.message : String(err)}
|
|
543
|
+
`);
|
|
543
544
|
this.saveIndexJson();
|
|
544
545
|
}
|
|
545
546
|
}
|
|
@@ -551,7 +552,9 @@ var RecallEngine = class {
|
|
|
551
552
|
const raw = fs3.readFileSync(indexPath, "utf-8");
|
|
552
553
|
this.entries = JSON.parse(raw);
|
|
553
554
|
}
|
|
554
|
-
} catch {
|
|
555
|
+
} catch (err) {
|
|
556
|
+
process.stderr.write(`[smriti:recall] JSON index load failed: ${err instanceof Error ? err.message : String(err)}
|
|
557
|
+
`);
|
|
555
558
|
this.entries = [];
|
|
556
559
|
}
|
|
557
560
|
}
|
|
@@ -559,21 +562,18 @@ var RecallEngine = class {
|
|
|
559
562
|
try {
|
|
560
563
|
const dir = getIndexDir();
|
|
561
564
|
fs3.mkdirSync(dir, { recursive: true });
|
|
562
|
-
fs3.writeFileSync(
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
);
|
|
567
|
-
} catch {
|
|
565
|
+
fs3.writeFileSync(getEmbeddingsPath(), JSON.stringify(this.entries, null, " "), "utf-8");
|
|
566
|
+
} catch (err) {
|
|
567
|
+
process.stderr.write(`[smriti:recall] JSON index save failed: ${err instanceof Error ? err.message : String(err)}
|
|
568
|
+
`);
|
|
568
569
|
}
|
|
569
570
|
}
|
|
570
571
|
// ─── Session Indexing ────────────────────────────────────────────
|
|
571
572
|
/** Index a session's turns into the embedding store. */
|
|
572
573
|
async indexSession(session) {
|
|
573
|
-
if (!this.loaded)
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
);
|
|
574
|
+
if (!this.loaded)
|
|
575
|
+
this.loadIndex();
|
|
576
|
+
this.entries = this.entries.filter((e) => !(e.source === "session" && e.sourceId === session.meta.id));
|
|
577
577
|
const indexText = extractIndexText(session);
|
|
578
578
|
const summary = summarizeSession(session);
|
|
579
579
|
const chunkSize = 4e3;
|
|
@@ -583,7 +583,8 @@ var RecallEngine = class {
|
|
|
583
583
|
} else {
|
|
584
584
|
for (let i = 0; i < indexText.length; i += chunkSize - 500) {
|
|
585
585
|
chunks.push(indexText.slice(i, i + chunkSize));
|
|
586
|
-
if (i + chunkSize >= indexText.length)
|
|
586
|
+
if (i + chunkSize >= indexText.length)
|
|
587
|
+
break;
|
|
587
588
|
}
|
|
588
589
|
}
|
|
589
590
|
for (let i = 0; i < chunks.length; i++) {
|
|
@@ -604,12 +605,12 @@ var RecallEngine = class {
|
|
|
604
605
|
}
|
|
605
606
|
/** Index a memory stream into the embedding store. */
|
|
606
607
|
async indexStream(streamType, content, deviceId) {
|
|
607
|
-
if (!this.loaded)
|
|
608
|
+
if (!this.loaded)
|
|
609
|
+
this.loadIndex();
|
|
608
610
|
const sourceId = deviceId ? `stream-${streamType}-${deviceId}` : `stream-${streamType}`;
|
|
609
|
-
this.entries = this.entries.filter(
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
if (!content || content.trim().length === 0) return;
|
|
611
|
+
this.entries = this.entries.filter((e) => !(e.source === "stream" && e.sourceId === sourceId));
|
|
612
|
+
if (!content || content.trim().length === 0)
|
|
613
|
+
return;
|
|
613
614
|
const vector = await getEmbedding(content.slice(0, 8e3));
|
|
614
615
|
this.entries.push({
|
|
615
616
|
id: sourceId,
|
|
@@ -628,23 +629,28 @@ var RecallEngine = class {
|
|
|
628
629
|
// ─── Recall (Search) ─────────────────────────────────────────────
|
|
629
630
|
/** Search all indexed embeddings for the given query string. */
|
|
630
631
|
async recall(query, options) {
|
|
631
|
-
if (!this.loaded)
|
|
632
|
-
|
|
632
|
+
if (!this.loaded)
|
|
633
|
+
this.loadIndex();
|
|
634
|
+
if (this.entries.length === 0)
|
|
635
|
+
return [];
|
|
633
636
|
const topK = options?.topK ?? DEFAULT_TOP_K;
|
|
634
637
|
const threshold = options?.threshold ?? DEFAULT_THRESHOLD;
|
|
635
638
|
const queryVector = await getEmbedding(query);
|
|
636
639
|
const scored = [];
|
|
637
640
|
for (const entry of this.entries) {
|
|
638
|
-
if (options?.deviceFilter && entry.deviceId !== options.deviceFilter)
|
|
641
|
+
if (options?.deviceFilter && entry.deviceId !== options.deviceFilter)
|
|
642
|
+
continue;
|
|
639
643
|
if (options?.dateRange) {
|
|
640
644
|
const entryDate = new Date(entry.date).getTime();
|
|
641
645
|
const rangeStart = new Date(options.dateRange[0]).getTime();
|
|
642
646
|
const rangeEnd = new Date(options.dateRange[1]).getTime();
|
|
643
|
-
if (entryDate < rangeStart || entryDate > rangeEnd)
|
|
647
|
+
if (entryDate < rangeStart || entryDate > rangeEnd)
|
|
648
|
+
continue;
|
|
644
649
|
}
|
|
645
650
|
if (options?.tagFilter && options.tagFilter.length > 0) {
|
|
646
651
|
const hasTag = options.tagFilter.some((tag) => entry.tags.includes(tag));
|
|
647
|
-
if (!hasTag)
|
|
652
|
+
if (!hasTag)
|
|
653
|
+
continue;
|
|
648
654
|
}
|
|
649
655
|
const score = cosineSimilarity(queryVector, entry.vector);
|
|
650
656
|
if (score >= threshold) {
|
|
@@ -655,8 +661,10 @@ var RecallEngine = class {
|
|
|
655
661
|
const seen = /* @__PURE__ */ new Set();
|
|
656
662
|
const results = [];
|
|
657
663
|
for (const { entry, score } of scored) {
|
|
658
|
-
if (results.length >= topK)
|
|
659
|
-
|
|
664
|
+
if (results.length >= topK)
|
|
665
|
+
break;
|
|
666
|
+
if (seen.has(entry.sourceId))
|
|
667
|
+
continue;
|
|
660
668
|
seen.add(entry.sourceId);
|
|
661
669
|
results.push({
|
|
662
670
|
sessionId: entry.sourceId,
|
|
@@ -678,7 +686,9 @@ var RecallEngine = class {
|
|
|
678
686
|
try {
|
|
679
687
|
const session = loadSession(meta.id, meta.project);
|
|
680
688
|
await this.indexSession(session);
|
|
681
|
-
} catch {
|
|
689
|
+
} catch (err) {
|
|
690
|
+
process.stderr.write(`[smriti:recall] reindex session ${meta.id} failed: ${err instanceof Error ? err.message : String(err)}
|
|
691
|
+
`);
|
|
682
692
|
}
|
|
683
693
|
}
|
|
684
694
|
const streamManager = new StreamManager();
|
|
@@ -722,4 +732,4 @@ export {
|
|
|
722
732
|
_resetRecallDbInit,
|
|
723
733
|
RecallEngine
|
|
724
734
|
};
|
|
725
|
-
//# sourceMappingURL=chunk-
|
|
735
|
+
//# sourceMappingURL=chunk-ARZCIITZ.js.map
|
|
@@ -621,6 +621,9 @@ function prepareSessionStatements(db) {
|
|
|
621
621
|
update: db.prepare(
|
|
622
622
|
"UPDATE sessions SET key = @key, updated_at = @updated_at, user_id = @user_id, channel = @channel, chat_type = @chat_type, chat_id = @chat_id, peer_id = @peer_id, account_id = @account_id, thread_id = @thread_id, label = @label, current_provider = @current_provider, current_model = @current_model, providers_used = @providers_used, provider_switches = @provider_switches WHERE id = @id"
|
|
623
623
|
),
|
|
624
|
+
touch: db.prepare(
|
|
625
|
+
"UPDATE sessions SET updated_at = @updated_at WHERE id = @id"
|
|
626
|
+
),
|
|
624
627
|
eventInsert: db.prepare(
|
|
625
628
|
"INSERT INTO session_events (id, session_id, role, content, metadata, created_at) VALUES (@id, @session_id, @role, @content, @metadata, @created_at)"
|
|
626
629
|
),
|
|
@@ -828,6 +831,10 @@ async function appendSessionEvent(s, event) {
|
|
|
828
831
|
metadata: event.metadata ? JSON.stringify(event.metadata) : null,
|
|
829
832
|
created_at: event.createdAt
|
|
830
833
|
});
|
|
834
|
+
s.touch.run({
|
|
835
|
+
id: event.sessionId,
|
|
836
|
+
updated_at: event.createdAt ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
837
|
+
});
|
|
831
838
|
}
|
|
832
839
|
async function listSessionEvents(s, sessionId, options) {
|
|
833
840
|
const limit = options?.limit ?? 50;
|
|
@@ -889,10 +896,14 @@ async function getSessionPrefs(s, sessionId) {
|
|
|
889
896
|
async function setSessionPrefs(s, sessionId, prefs) {
|
|
890
897
|
const existing = await getSessionPrefs(s, sessionId);
|
|
891
898
|
const now2 = (/* @__PURE__ */ new Date()).toISOString();
|
|
892
|
-
const
|
|
893
|
-
const
|
|
894
|
-
const
|
|
895
|
-
const
|
|
899
|
+
const hasProviderId = Object.prototype.hasOwnProperty.call(prefs, "providerId");
|
|
900
|
+
const providerId = hasProviderId ? prefs.providerId ?? null : existing?.providerId ?? null;
|
|
901
|
+
const hasModel = Object.prototype.hasOwnProperty.call(prefs, "model");
|
|
902
|
+
const model = hasModel ? prefs.model ?? null : existing?.model ?? null;
|
|
903
|
+
const hasSystem = Object.prototype.hasOwnProperty.call(prefs, "system");
|
|
904
|
+
const system = hasSystem ? prefs.system ?? null : existing?.system ?? null;
|
|
905
|
+
const hasAutoRouting = Object.prototype.hasOwnProperty.call(prefs, "autoRouting");
|
|
906
|
+
const autoRouting = hasAutoRouting ? prefs.autoRouting ?? null : existing?.autoRouting;
|
|
896
907
|
const hasLanguage = Object.prototype.hasOwnProperty.call(prefs, "language");
|
|
897
908
|
const language = hasLanguage ? prefs.language ?? null : existing?.language ?? null;
|
|
898
909
|
const hasLanguageUpdatedAt = Object.prototype.hasOwnProperty.call(prefs, "languageUpdatedAt");
|
|
@@ -946,7 +957,7 @@ async function setSessionPrefs(s, sessionId, prefs) {
|
|
|
946
957
|
providerId: providerId ?? void 0,
|
|
947
958
|
model: model ?? void 0,
|
|
948
959
|
system: system ?? void 0,
|
|
949
|
-
autoRouting,
|
|
960
|
+
autoRouting: autoRouting ?? void 0,
|
|
950
961
|
language: language ?? void 0,
|
|
951
962
|
languageUpdatedAt: languageUpdatedAt ?? void 0,
|
|
952
963
|
continuityPreferredDeviceId: continuityPreferredDeviceId ?? void 0,
|
|
@@ -2790,4 +2801,4 @@ export {
|
|
|
2790
2801
|
deleteReaction,
|
|
2791
2802
|
SqliteStorage
|
|
2792
2803
|
};
|
|
2793
|
-
//# sourceMappingURL=chunk-
|
|
2804
|
+
//# sourceMappingURL=chunk-EG37M4QL.js.map
|