@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
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
2
|
listSessions,
|
|
3
3
|
loadSession
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ZYY6N3SP.js";
|
|
5
5
|
import {
|
|
6
6
|
EmbeddingService,
|
|
7
7
|
cosineSimilarity,
|
|
8
8
|
estimateTokens
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-A3HOZBC5.js";
|
|
10
10
|
import {
|
|
11
11
|
initVectorsSchema
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-V2ZIKDN4.js";
|
|
13
13
|
import {
|
|
14
14
|
DatabaseManager
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-67DXWEKG.js";
|
|
16
16
|
import {
|
|
17
17
|
getChitraguptaHome
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-2OBLQJYJ.js";
|
|
19
19
|
|
|
20
|
-
// ../chitragupta/packages/smriti/
|
|
21
|
-
import
|
|
22
|
-
import path2 from "path";
|
|
20
|
+
// ../chitragupta/packages/smriti/dist/recall.js
|
|
21
|
+
import fs3 from "fs";
|
|
23
22
|
|
|
24
|
-
// ../chitragupta/packages/smriti/
|
|
23
|
+
// ../chitragupta/packages/smriti/dist/streams.js
|
|
25
24
|
import fs from "fs";
|
|
26
25
|
import path from "path";
|
|
27
26
|
var STREAM_CONFIGS = {
|
|
@@ -51,9 +50,7 @@ var STREAM_CONFIGS = {
|
|
|
51
50
|
}
|
|
52
51
|
};
|
|
53
52
|
var STREAM_ORDER = ["identity", "projects", "tasks", "flow"];
|
|
54
|
-
var PRESERVATION_RATIOS = STREAM_ORDER.map(
|
|
55
|
-
(s) => STREAM_CONFIGS[s].preservation
|
|
56
|
-
);
|
|
53
|
+
var PRESERVATION_RATIOS = STREAM_ORDER.map((s) => STREAM_CONFIGS[s].preservation);
|
|
57
54
|
function getStreamsRoot() {
|
|
58
55
|
return path.join(getChitraguptaHome(), "smriti", "streams");
|
|
59
56
|
}
|
|
@@ -167,7 +164,8 @@ var StreamManager = class {
|
|
|
167
164
|
*/
|
|
168
165
|
readContent(streamType, deviceId) {
|
|
169
166
|
const raw = this.read(streamType, deviceId);
|
|
170
|
-
if (!raw)
|
|
167
|
+
if (!raw)
|
|
168
|
+
return "";
|
|
171
169
|
const { content } = parseStreamFile(raw);
|
|
172
170
|
return content;
|
|
173
171
|
}
|
|
@@ -241,10 +239,7 @@ ${entry}`;
|
|
|
241
239
|
* than ephemeral streams (flow).
|
|
242
240
|
*/
|
|
243
241
|
getStreamBudgets(totalBudget) {
|
|
244
|
-
const totalPreservation = STREAM_ORDER.reduce(
|
|
245
|
-
(sum, s) => sum + STREAM_CONFIGS[s].preservation,
|
|
246
|
-
0
|
|
247
|
-
);
|
|
242
|
+
const totalPreservation = STREAM_ORDER.reduce((sum, s) => sum + STREAM_CONFIGS[s].preservation, 0);
|
|
248
243
|
const budgets = {};
|
|
249
244
|
for (const stream of STREAM_ORDER) {
|
|
250
245
|
const ratio = STREAM_CONFIGS[stream].preservation / totalPreservation;
|
|
@@ -269,9 +264,11 @@ ${entry}`;
|
|
|
269
264
|
*/
|
|
270
265
|
enforcePreservation(streamType, maxTokens, deviceId) {
|
|
271
266
|
const raw = this.read(streamType, deviceId);
|
|
272
|
-
if (!raw)
|
|
267
|
+
if (!raw)
|
|
268
|
+
return 0;
|
|
273
269
|
const currentTokens = estimateTokens(raw);
|
|
274
|
-
if (currentTokens <= maxTokens)
|
|
270
|
+
if (currentTokens <= maxTokens)
|
|
271
|
+
return 0;
|
|
275
272
|
const { content } = parseStreamFile(raw);
|
|
276
273
|
const ENTRY_SEP = /(\n\n\*\d{4}-)/;
|
|
277
274
|
const parts = content.split(ENTRY_SEP);
|
|
@@ -313,7 +310,8 @@ ${entry}`;
|
|
|
313
310
|
*/
|
|
314
311
|
listFlowDevices() {
|
|
315
312
|
const flowDir = path.join(this.root, "flow");
|
|
316
|
-
if (!fs.existsSync(flowDir))
|
|
313
|
+
if (!fs.existsSync(flowDir))
|
|
314
|
+
return [];
|
|
317
315
|
try {
|
|
318
316
|
return fs.readdirSync(flowDir).filter((f) => f.endsWith(".md")).map((f) => f.replace(/\.md$/, ""));
|
|
319
317
|
} catch {
|
|
@@ -328,7 +326,7 @@ ${entry}`;
|
|
|
328
326
|
}
|
|
329
327
|
};
|
|
330
328
|
|
|
331
|
-
// ../chitragupta/packages/smriti/
|
|
329
|
+
// ../chitragupta/packages/smriti/dist/recall-scoring.js
|
|
332
330
|
var _embeddingService = new EmbeddingService();
|
|
333
331
|
function configureRecallScoring(options) {
|
|
334
332
|
if (options.embeddingService) {
|
|
@@ -344,7 +342,8 @@ function summarizeSession(session) {
|
|
|
344
342
|
if (turn.role === "user") {
|
|
345
343
|
parts.push(turn.content.slice(0, 200));
|
|
346
344
|
}
|
|
347
|
-
if (parts.join(" ").length > 400)
|
|
345
|
+
if (parts.join(" ").length > 400)
|
|
346
|
+
break;
|
|
348
347
|
}
|
|
349
348
|
return parts.join(" | ").slice(0, 500);
|
|
350
349
|
}
|
|
@@ -368,7 +367,9 @@ function resetOllamaAvailability() {
|
|
|
368
367
|
_embeddingService.resetAvailability();
|
|
369
368
|
}
|
|
370
369
|
|
|
371
|
-
// ../chitragupta/packages/smriti/
|
|
370
|
+
// ../chitragupta/packages/smriti/dist/recall-storage.js
|
|
371
|
+
import fs2 from "fs";
|
|
372
|
+
import path2 from "path";
|
|
372
373
|
var DEFAULT_TOP_K = 10;
|
|
373
374
|
var DEFAULT_THRESHOLD = 0.3;
|
|
374
375
|
function getIndexDir() {
|
|
@@ -382,13 +383,66 @@ function vectorToBlob(vector) {
|
|
|
382
383
|
return Buffer.from(float32.buffer);
|
|
383
384
|
}
|
|
384
385
|
function blobToVector(blob) {
|
|
385
|
-
const float32 = new Float32Array(
|
|
386
|
-
blob.buffer,
|
|
387
|
-
blob.byteOffset,
|
|
388
|
-
blob.byteLength / 4
|
|
389
|
-
);
|
|
386
|
+
const float32 = new Float32Array(blob.buffer, blob.byteOffset, blob.byteLength / 4);
|
|
390
387
|
return Array.from(float32);
|
|
391
388
|
}
|
|
389
|
+
function migrateEmbeddingsJson() {
|
|
390
|
+
const jsonPath = getEmbeddingsPath();
|
|
391
|
+
if (!fs2.existsSync(jsonPath)) {
|
|
392
|
+
return { migrated: 0, skipped: 0 };
|
|
393
|
+
}
|
|
394
|
+
let entries;
|
|
395
|
+
try {
|
|
396
|
+
const raw = fs2.readFileSync(jsonPath, "utf-8");
|
|
397
|
+
entries = JSON.parse(raw);
|
|
398
|
+
} catch {
|
|
399
|
+
return { migrated: 0, skipped: 0 };
|
|
400
|
+
}
|
|
401
|
+
if (!entries || entries.length === 0) {
|
|
402
|
+
return { migrated: 0, skipped: 0 };
|
|
403
|
+
}
|
|
404
|
+
let migrated = 0;
|
|
405
|
+
let skipped = 0;
|
|
406
|
+
try {
|
|
407
|
+
const dbm = DatabaseManager.instance();
|
|
408
|
+
initVectorsSchema(dbm);
|
|
409
|
+
const db = dbm.get("vectors");
|
|
410
|
+
const txn = db.transaction(() => {
|
|
411
|
+
const insert = db.prepare(`
|
|
412
|
+
INSERT OR IGNORE INTO embeddings (id, vector, text, source_type, source_id, dimensions, metadata, created_at)
|
|
413
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
414
|
+
`);
|
|
415
|
+
for (const entry of entries) {
|
|
416
|
+
try {
|
|
417
|
+
const result = insert.run(entry.id, vectorToBlob(entry.vector), entry.text, entry.source, entry.sourceId, entry.vector.length, JSON.stringify({
|
|
418
|
+
title: entry.title,
|
|
419
|
+
summary: entry.summary,
|
|
420
|
+
tags: entry.tags,
|
|
421
|
+
date: entry.date,
|
|
422
|
+
deviceId: entry.deviceId
|
|
423
|
+
}), new Date(entry.date).getTime());
|
|
424
|
+
if (result.changes > 0) {
|
|
425
|
+
migrated++;
|
|
426
|
+
} else {
|
|
427
|
+
skipped++;
|
|
428
|
+
}
|
|
429
|
+
} catch {
|
|
430
|
+
skipped++;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
txn();
|
|
435
|
+
try {
|
|
436
|
+
fs2.renameSync(jsonPath, jsonPath + ".bak");
|
|
437
|
+
} catch {
|
|
438
|
+
}
|
|
439
|
+
} catch {
|
|
440
|
+
return { migrated: 0, skipped: entries.length };
|
|
441
|
+
}
|
|
442
|
+
return { migrated, skipped };
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// ../chitragupta/packages/smriti/dist/recall.js
|
|
392
446
|
var _dbInitialized = false;
|
|
393
447
|
function _resetRecallDbInit() {
|
|
394
448
|
_dbInitialized = false;
|
|
@@ -453,22 +507,13 @@ var RecallEngine = class {
|
|
|
453
507
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
454
508
|
`);
|
|
455
509
|
for (const entry of this.entries) {
|
|
456
|
-
insert.run(
|
|
457
|
-
entry.
|
|
458
|
-
|
|
459
|
-
entry.
|
|
460
|
-
entry.
|
|
461
|
-
entry.
|
|
462
|
-
|
|
463
|
-
JSON.stringify({
|
|
464
|
-
title: entry.title,
|
|
465
|
-
summary: entry.summary,
|
|
466
|
-
tags: entry.tags,
|
|
467
|
-
date: entry.date,
|
|
468
|
-
deviceId: entry.deviceId
|
|
469
|
-
}),
|
|
470
|
-
new Date(entry.date).getTime()
|
|
471
|
-
);
|
|
510
|
+
insert.run(entry.id, vectorToBlob(entry.vector), entry.text, entry.source, entry.sourceId, entry.vector.length, JSON.stringify({
|
|
511
|
+
title: entry.title,
|
|
512
|
+
summary: entry.summary,
|
|
513
|
+
tags: entry.tags,
|
|
514
|
+
date: entry.date,
|
|
515
|
+
deviceId: entry.deviceId
|
|
516
|
+
}), new Date(entry.date).getTime());
|
|
472
517
|
}
|
|
473
518
|
});
|
|
474
519
|
txn();
|
|
@@ -480,8 +525,8 @@ var RecallEngine = class {
|
|
|
480
525
|
loadIndexJson() {
|
|
481
526
|
try {
|
|
482
527
|
const indexPath = getEmbeddingsPath();
|
|
483
|
-
if (
|
|
484
|
-
const raw =
|
|
528
|
+
if (fs3.existsSync(indexPath)) {
|
|
529
|
+
const raw = fs3.readFileSync(indexPath, "utf-8");
|
|
485
530
|
this.entries = JSON.parse(raw);
|
|
486
531
|
}
|
|
487
532
|
} catch {
|
|
@@ -491,21 +536,17 @@ var RecallEngine = class {
|
|
|
491
536
|
saveIndexJson() {
|
|
492
537
|
try {
|
|
493
538
|
const dir = getIndexDir();
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
getEmbeddingsPath(),
|
|
497
|
-
JSON.stringify(this.entries, null, " "),
|
|
498
|
-
"utf-8"
|
|
499
|
-
);
|
|
539
|
+
fs3.mkdirSync(dir, { recursive: true });
|
|
540
|
+
fs3.writeFileSync(getEmbeddingsPath(), JSON.stringify(this.entries, null, " "), "utf-8");
|
|
500
541
|
} catch {
|
|
501
542
|
}
|
|
502
543
|
}
|
|
503
544
|
// ─── Session Indexing ────────────────────────────────────────────
|
|
545
|
+
/** Index a session's turns into the embedding store. */
|
|
504
546
|
async indexSession(session) {
|
|
505
|
-
if (!this.loaded)
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
);
|
|
547
|
+
if (!this.loaded)
|
|
548
|
+
this.loadIndex();
|
|
549
|
+
this.entries = this.entries.filter((e) => !(e.source === "session" && e.sourceId === session.meta.id));
|
|
509
550
|
const indexText = extractIndexText(session);
|
|
510
551
|
const summary = summarizeSession(session);
|
|
511
552
|
const chunkSize = 4e3;
|
|
@@ -515,7 +556,8 @@ var RecallEngine = class {
|
|
|
515
556
|
} else {
|
|
516
557
|
for (let i = 0; i < indexText.length; i += chunkSize - 500) {
|
|
517
558
|
chunks.push(indexText.slice(i, i + chunkSize));
|
|
518
|
-
if (i + chunkSize >= indexText.length)
|
|
559
|
+
if (i + chunkSize >= indexText.length)
|
|
560
|
+
break;
|
|
519
561
|
}
|
|
520
562
|
}
|
|
521
563
|
for (let i = 0; i < chunks.length; i++) {
|
|
@@ -534,13 +576,14 @@ var RecallEngine = class {
|
|
|
534
576
|
}
|
|
535
577
|
this.saveIndex();
|
|
536
578
|
}
|
|
579
|
+
/** Index a memory stream into the embedding store. */
|
|
537
580
|
async indexStream(streamType, content, deviceId) {
|
|
538
|
-
if (!this.loaded)
|
|
581
|
+
if (!this.loaded)
|
|
582
|
+
this.loadIndex();
|
|
539
583
|
const sourceId = deviceId ? `stream-${streamType}-${deviceId}` : `stream-${streamType}`;
|
|
540
|
-
this.entries = this.entries.filter(
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
if (!content || content.trim().length === 0) return;
|
|
584
|
+
this.entries = this.entries.filter((e) => !(e.source === "stream" && e.sourceId === sourceId));
|
|
585
|
+
if (!content || content.trim().length === 0)
|
|
586
|
+
return;
|
|
544
587
|
const vector = await getEmbedding(content.slice(0, 8e3));
|
|
545
588
|
this.entries.push({
|
|
546
589
|
id: sourceId,
|
|
@@ -557,24 +600,30 @@ var RecallEngine = class {
|
|
|
557
600
|
this.saveIndex();
|
|
558
601
|
}
|
|
559
602
|
// ─── Recall (Search) ─────────────────────────────────────────────
|
|
603
|
+
/** Search all indexed embeddings for the given query string. */
|
|
560
604
|
async recall(query, options) {
|
|
561
|
-
if (!this.loaded)
|
|
562
|
-
|
|
605
|
+
if (!this.loaded)
|
|
606
|
+
this.loadIndex();
|
|
607
|
+
if (this.entries.length === 0)
|
|
608
|
+
return [];
|
|
563
609
|
const topK = options?.topK ?? DEFAULT_TOP_K;
|
|
564
610
|
const threshold = options?.threshold ?? DEFAULT_THRESHOLD;
|
|
565
611
|
const queryVector = await getEmbedding(query);
|
|
566
612
|
const scored = [];
|
|
567
613
|
for (const entry of this.entries) {
|
|
568
|
-
if (options?.deviceFilter && entry.deviceId !== options.deviceFilter)
|
|
614
|
+
if (options?.deviceFilter && entry.deviceId !== options.deviceFilter)
|
|
615
|
+
continue;
|
|
569
616
|
if (options?.dateRange) {
|
|
570
617
|
const entryDate = new Date(entry.date).getTime();
|
|
571
618
|
const rangeStart = new Date(options.dateRange[0]).getTime();
|
|
572
619
|
const rangeEnd = new Date(options.dateRange[1]).getTime();
|
|
573
|
-
if (entryDate < rangeStart || entryDate > rangeEnd)
|
|
620
|
+
if (entryDate < rangeStart || entryDate > rangeEnd)
|
|
621
|
+
continue;
|
|
574
622
|
}
|
|
575
623
|
if (options?.tagFilter && options.tagFilter.length > 0) {
|
|
576
624
|
const hasTag = options.tagFilter.some((tag) => entry.tags.includes(tag));
|
|
577
|
-
if (!hasTag)
|
|
625
|
+
if (!hasTag)
|
|
626
|
+
continue;
|
|
578
627
|
}
|
|
579
628
|
const score = cosineSimilarity(queryVector, entry.vector);
|
|
580
629
|
if (score >= threshold) {
|
|
@@ -585,8 +634,10 @@ var RecallEngine = class {
|
|
|
585
634
|
const seen = /* @__PURE__ */ new Set();
|
|
586
635
|
const results = [];
|
|
587
636
|
for (const { entry, score } of scored) {
|
|
588
|
-
if (results.length >= topK)
|
|
589
|
-
|
|
637
|
+
if (results.length >= topK)
|
|
638
|
+
break;
|
|
639
|
+
if (seen.has(entry.sourceId))
|
|
640
|
+
continue;
|
|
590
641
|
seen.add(entry.sourceId);
|
|
591
642
|
results.push({
|
|
592
643
|
sessionId: entry.sourceId,
|
|
@@ -600,6 +651,7 @@ var RecallEngine = class {
|
|
|
600
651
|
return results;
|
|
601
652
|
}
|
|
602
653
|
// ─── Re-index ────────────────────────────────────────────────────
|
|
654
|
+
/** Re-index all sessions and streams from scratch. */
|
|
603
655
|
async reindexAll() {
|
|
604
656
|
this.entries = [];
|
|
605
657
|
const allMetas = listSessions();
|
|
@@ -629,77 +681,15 @@ var RecallEngine = class {
|
|
|
629
681
|
}
|
|
630
682
|
this.saveIndex();
|
|
631
683
|
}
|
|
684
|
+
/** Return the number of entries in the in-memory index. */
|
|
632
685
|
getIndexSize() {
|
|
633
686
|
return this.entries.length;
|
|
634
687
|
}
|
|
688
|
+
/** Reset the embedding provider availability cache. */
|
|
635
689
|
resetOllamaAvailability() {
|
|
636
690
|
resetOllamaAvailability();
|
|
637
691
|
}
|
|
638
692
|
};
|
|
639
|
-
function migrateEmbeddingsJson() {
|
|
640
|
-
const jsonPath = getEmbeddingsPath();
|
|
641
|
-
if (!fs2.existsSync(jsonPath)) {
|
|
642
|
-
return { migrated: 0, skipped: 0 };
|
|
643
|
-
}
|
|
644
|
-
let entries;
|
|
645
|
-
try {
|
|
646
|
-
const raw = fs2.readFileSync(jsonPath, "utf-8");
|
|
647
|
-
entries = JSON.parse(raw);
|
|
648
|
-
} catch {
|
|
649
|
-
return { migrated: 0, skipped: 0 };
|
|
650
|
-
}
|
|
651
|
-
if (!entries || entries.length === 0) {
|
|
652
|
-
return { migrated: 0, skipped: 0 };
|
|
653
|
-
}
|
|
654
|
-
let migrated = 0;
|
|
655
|
-
let skipped = 0;
|
|
656
|
-
try {
|
|
657
|
-
const dbm = DatabaseManager.instance();
|
|
658
|
-
initVectorsSchema(dbm);
|
|
659
|
-
const db = dbm.get("vectors");
|
|
660
|
-
const txn = db.transaction(() => {
|
|
661
|
-
const insert = db.prepare(`
|
|
662
|
-
INSERT OR IGNORE INTO embeddings (id, vector, text, source_type, source_id, dimensions, metadata, created_at)
|
|
663
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
664
|
-
`);
|
|
665
|
-
for (const entry of entries) {
|
|
666
|
-
try {
|
|
667
|
-
const result = insert.run(
|
|
668
|
-
entry.id,
|
|
669
|
-
vectorToBlob(entry.vector),
|
|
670
|
-
entry.text,
|
|
671
|
-
entry.source,
|
|
672
|
-
entry.sourceId,
|
|
673
|
-
entry.vector.length,
|
|
674
|
-
JSON.stringify({
|
|
675
|
-
title: entry.title,
|
|
676
|
-
summary: entry.summary,
|
|
677
|
-
tags: entry.tags,
|
|
678
|
-
date: entry.date,
|
|
679
|
-
deviceId: entry.deviceId
|
|
680
|
-
}),
|
|
681
|
-
new Date(entry.date).getTime()
|
|
682
|
-
);
|
|
683
|
-
if (result.changes > 0) {
|
|
684
|
-
migrated++;
|
|
685
|
-
} else {
|
|
686
|
-
skipped++;
|
|
687
|
-
}
|
|
688
|
-
} catch {
|
|
689
|
-
skipped++;
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
});
|
|
693
|
-
txn();
|
|
694
|
-
try {
|
|
695
|
-
fs2.renameSync(jsonPath, jsonPath + ".bak");
|
|
696
|
-
} catch {
|
|
697
|
-
}
|
|
698
|
-
} catch {
|
|
699
|
-
return { migrated: 0, skipped: entries.length };
|
|
700
|
-
}
|
|
701
|
-
return { migrated, skipped };
|
|
702
|
-
}
|
|
703
693
|
|
|
704
694
|
export {
|
|
705
695
|
STREAM_CONFIGS,
|
|
@@ -709,8 +699,8 @@ export {
|
|
|
709
699
|
configureRecallScoring,
|
|
710
700
|
vectorToBlob,
|
|
711
701
|
blobToVector,
|
|
702
|
+
migrateEmbeddingsJson,
|
|
712
703
|
_resetRecallDbInit,
|
|
713
|
-
RecallEngine
|
|
714
|
-
migrateEmbeddingsJson
|
|
704
|
+
RecallEngine
|
|
715
705
|
};
|
|
716
|
-
//# sourceMappingURL=chunk-
|
|
706
|
+
//# sourceMappingURL=chunk-D46QTN3G.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
|