@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,21 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
initAgentSchema
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-V2ZIKDN4.js";
|
|
4
4
|
import {
|
|
5
5
|
DatabaseManager
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-67DXWEKG.js";
|
|
7
7
|
import {
|
|
8
8
|
SessionError,
|
|
9
9
|
getChitraguptaHome
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-2OBLQJYJ.js";
|
|
11
11
|
|
|
12
|
-
// ../chitragupta/packages/smriti/
|
|
12
|
+
// ../chitragupta/packages/smriti/dist/session-store.js
|
|
13
13
|
import fs from "fs";
|
|
14
14
|
import { renameSync as nodeRenameSync } from "node:fs";
|
|
15
15
|
import path from "path";
|
|
16
16
|
import crypto from "crypto";
|
|
17
17
|
|
|
18
|
-
// ../chitragupta/packages/smriti/
|
|
18
|
+
// ../chitragupta/packages/smriti/dist/markdown-parser.js
|
|
19
19
|
function parseFrontmatter(yaml) {
|
|
20
20
|
const result = {};
|
|
21
21
|
const lines = yaml.split("\n");
|
|
@@ -23,7 +23,8 @@ function parseFrontmatter(yaml) {
|
|
|
23
23
|
let currentArray = null;
|
|
24
24
|
for (const line of lines) {
|
|
25
25
|
const trimmed = line.trim();
|
|
26
|
-
if (!trimmed || trimmed.startsWith("#"))
|
|
26
|
+
if (!trimmed || trimmed.startsWith("#"))
|
|
27
|
+
continue;
|
|
27
28
|
if (trimmed.startsWith("- ") && currentKey && currentArray !== null) {
|
|
28
29
|
currentArray.push(trimmed.slice(2).trim());
|
|
29
30
|
continue;
|
|
@@ -34,7 +35,8 @@ function parseFrontmatter(yaml) {
|
|
|
34
35
|
currentKey = null;
|
|
35
36
|
}
|
|
36
37
|
const colonIdx = trimmed.indexOf(":");
|
|
37
|
-
if (colonIdx === -1)
|
|
38
|
+
if (colonIdx === -1)
|
|
39
|
+
continue;
|
|
38
40
|
const key = trimmed.slice(0, colonIdx).trim();
|
|
39
41
|
const rawValue = trimmed.slice(colonIdx + 1).trim();
|
|
40
42
|
if (rawValue === "" || rawValue === void 0) {
|
|
@@ -59,9 +61,12 @@ function parseFrontmatter(yaml) {
|
|
|
59
61
|
return result;
|
|
60
62
|
}
|
|
61
63
|
function parseScalar(value) {
|
|
62
|
-
if (value === "null" || value === "~")
|
|
63
|
-
|
|
64
|
-
if (value === "
|
|
64
|
+
if (value === "null" || value === "~")
|
|
65
|
+
return null;
|
|
66
|
+
if (value === "true")
|
|
67
|
+
return true;
|
|
68
|
+
if (value === "false")
|
|
69
|
+
return false;
|
|
65
70
|
if (value.startsWith('"') && value.endsWith('"')) {
|
|
66
71
|
return value.slice(1, -1).replace(/\\"/g, '"');
|
|
67
72
|
}
|
|
@@ -69,7 +74,8 @@ function parseScalar(value) {
|
|
|
69
74
|
return value.slice(1, -1);
|
|
70
75
|
}
|
|
71
76
|
const num = Number(value);
|
|
72
|
-
if (!Number.isNaN(num) && value !== "")
|
|
77
|
+
if (!Number.isNaN(num) && value !== "")
|
|
78
|
+
return num;
|
|
73
79
|
return value;
|
|
74
80
|
}
|
|
75
81
|
function parseSessionMarkdown(content) {
|
|
@@ -103,7 +109,8 @@ function buildSessionMeta(raw) {
|
|
|
103
109
|
};
|
|
104
110
|
}
|
|
105
111
|
function parseTurns(body) {
|
|
106
|
-
if (!body)
|
|
112
|
+
if (!body)
|
|
113
|
+
return [];
|
|
107
114
|
body = stripFooter(body);
|
|
108
115
|
const turnPattern = /^## Turn (\d+) — (user|assistant)(?:\s+\(([^)]*)\))?/gm;
|
|
109
116
|
const turns = [];
|
|
@@ -129,8 +136,10 @@ function parseTurns(body) {
|
|
|
129
136
|
const parts = m.meta.split(",").map((s) => s.trim());
|
|
130
137
|
for (const part of parts) {
|
|
131
138
|
const [k, v] = part.split(":").map((s) => s.trim());
|
|
132
|
-
if (k === "agent")
|
|
133
|
-
|
|
139
|
+
if (k === "agent")
|
|
140
|
+
agent = v;
|
|
141
|
+
if (k === "model")
|
|
142
|
+
model = v;
|
|
134
143
|
}
|
|
135
144
|
}
|
|
136
145
|
const { content, toolCalls } = parseContentAndToolCalls(rawContent);
|
|
@@ -140,9 +149,12 @@ function parseTurns(body) {
|
|
|
140
149
|
role: m.role,
|
|
141
150
|
content: unescapedContent
|
|
142
151
|
};
|
|
143
|
-
if (agent)
|
|
144
|
-
|
|
145
|
-
if (
|
|
152
|
+
if (agent)
|
|
153
|
+
turn.agent = agent;
|
|
154
|
+
if (model)
|
|
155
|
+
turn.model = model;
|
|
156
|
+
if (toolCalls.length > 0)
|
|
157
|
+
turn.toolCalls = toolCalls;
|
|
146
158
|
turns.push(turn);
|
|
147
159
|
}
|
|
148
160
|
return turns;
|
|
@@ -193,11 +205,12 @@ function parseToolCallSection(name, section) {
|
|
|
193
205
|
}
|
|
194
206
|
}
|
|
195
207
|
const toolCall = { name, input, result };
|
|
196
|
-
if (isError)
|
|
208
|
+
if (isError)
|
|
209
|
+
toolCall.isError = true;
|
|
197
210
|
return toolCall;
|
|
198
211
|
}
|
|
199
212
|
|
|
200
|
-
// ../chitragupta/packages/smriti/
|
|
213
|
+
// ../chitragupta/packages/smriti/dist/markdown-writer.js
|
|
201
214
|
function writeFrontmatter(meta) {
|
|
202
215
|
const lines = [];
|
|
203
216
|
lines.push("---");
|
|
@@ -247,8 +260,10 @@ function writeTurn(turn) {
|
|
|
247
260
|
const lines = [];
|
|
248
261
|
let heading = `## Turn ${turn.turnNumber} \u2014 ${turn.role}`;
|
|
249
262
|
const metaParts = [];
|
|
250
|
-
if (turn.agent)
|
|
251
|
-
|
|
263
|
+
if (turn.agent)
|
|
264
|
+
metaParts.push(`agent: ${turn.agent}`);
|
|
265
|
+
if (turn.model)
|
|
266
|
+
metaParts.push(`model: ${turn.model}`);
|
|
252
267
|
if (metaParts.length > 0) {
|
|
253
268
|
heading += ` (${metaParts.join(", ")})`;
|
|
254
269
|
}
|
|
@@ -288,7 +303,7 @@ function writeTurnMarkdown(turn) {
|
|
|
288
303
|
return writeTurn(turn);
|
|
289
304
|
}
|
|
290
305
|
|
|
291
|
-
// ../chitragupta/packages/smriti/
|
|
306
|
+
// ../chitragupta/packages/smriti/dist/session-store.js
|
|
292
307
|
function atomicRename(tmpPath, targetPath) {
|
|
293
308
|
try {
|
|
294
309
|
nodeRenameSync(tmpPath, targetPath);
|
|
@@ -318,7 +333,8 @@ function cacheKey(id, project) {
|
|
|
318
333
|
function cacheGet(id, project) {
|
|
319
334
|
const key = cacheKey(id, project);
|
|
320
335
|
const entry = sessionCache.get(key);
|
|
321
|
-
if (!entry)
|
|
336
|
+
if (!entry)
|
|
337
|
+
return void 0;
|
|
322
338
|
const size = sessionCacheSizes.get(key) ?? 0;
|
|
323
339
|
sessionCache.delete(key);
|
|
324
340
|
sessionCacheSizes.delete(key);
|
|
@@ -335,7 +351,8 @@ function cachePut(id, project, session) {
|
|
|
335
351
|
const newSize = estimateSessionBytes(session);
|
|
336
352
|
while ((sessionCache.size >= SESSION_CACHE_MAX || sessionCacheBytes + newSize > SESSION_CACHE_MAX_BYTES) && sessionCache.size > 0) {
|
|
337
353
|
const oldest = sessionCache.keys().next().value;
|
|
338
|
-
if (oldest === void 0)
|
|
354
|
+
if (oldest === void 0)
|
|
355
|
+
break;
|
|
339
356
|
const evictedSize = sessionCacheSizes.get(oldest) ?? 0;
|
|
340
357
|
sessionCache.delete(oldest);
|
|
341
358
|
sessionCacheSizes.delete(oldest);
|
|
@@ -399,10 +416,12 @@ function resolveSessionPath(id, project) {
|
|
|
399
416
|
const dateMatch = id.match(/^session-(\d{4})-(\d{2})-\d{2}/);
|
|
400
417
|
if (dateMatch) {
|
|
401
418
|
const newPath = path.join(projectDir, dateMatch[1], dateMatch[2], `${id}.md`);
|
|
402
|
-
if (fs.existsSync(newPath))
|
|
419
|
+
if (fs.existsSync(newPath))
|
|
420
|
+
return newPath;
|
|
403
421
|
}
|
|
404
422
|
const oldPath = path.join(projectDir, `${id}.md`);
|
|
405
|
-
if (fs.existsSync(oldPath))
|
|
423
|
+
if (fs.existsSync(oldPath))
|
|
424
|
+
return oldPath;
|
|
406
425
|
if (dateMatch) {
|
|
407
426
|
return path.join(projectDir, dateMatch[1], dateMatch[2], `${id}.md`);
|
|
408
427
|
}
|
|
@@ -410,14 +429,14 @@ function resolveSessionPath(id, project) {
|
|
|
410
429
|
}
|
|
411
430
|
function patchFrontmatterUpdated(content, updatedIso) {
|
|
412
431
|
const fmMatch = content.match(/^---\n([\s\S]*?)\n---/);
|
|
413
|
-
if (!fmMatch)
|
|
432
|
+
if (!fmMatch)
|
|
433
|
+
return content;
|
|
414
434
|
const frontmatter = fmMatch[1];
|
|
415
|
-
if (!/^updated:\s/m.test(frontmatter))
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
if (patchedFrontmatter === frontmatter) return content;
|
|
435
|
+
if (!/^updated:\s/m.test(frontmatter))
|
|
436
|
+
return content;
|
|
437
|
+
const patchedFrontmatter = frontmatter.replace(/^updated:\s.*$/m, `updated: ${updatedIso}`);
|
|
438
|
+
if (patchedFrontmatter === frontmatter)
|
|
439
|
+
return content;
|
|
421
440
|
return `---
|
|
422
441
|
${patchedFrontmatter}
|
|
423
442
|
---${content.slice(fmMatch[0].length)}`;
|
|
@@ -516,37 +535,49 @@ function upsertSessionToDb(meta, filePath) {
|
|
|
516
535
|
`);
|
|
517
536
|
}
|
|
518
537
|
}
|
|
519
|
-
function
|
|
538
|
+
function isRecoverableSessionConstraintError(err) {
|
|
539
|
+
if (!(err instanceof Error))
|
|
540
|
+
return false;
|
|
541
|
+
const lower = err.message.toLowerCase();
|
|
542
|
+
return lower.includes("foreign key constraint failed") || lower.includes("constraint failed");
|
|
543
|
+
}
|
|
544
|
+
function seedSessionRowForTurn(sessionId, project, filePath) {
|
|
545
|
+
const db = getAgentDb();
|
|
546
|
+
const now = Date.now();
|
|
547
|
+
const normalizedFilePath = path.isAbsolute(filePath) ? path.relative(getChitraguptaHome(), filePath) : filePath;
|
|
548
|
+
db.prepare(`
|
|
549
|
+
INSERT OR IGNORE INTO sessions (id, project, title, created_at, updated_at, turn_count, file_path)
|
|
550
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
551
|
+
`).run(sessionId, project, "Recovered Session", now, now, 0, normalizedFilePath);
|
|
552
|
+
}
|
|
553
|
+
function insertTurnToDb(sessionId, turn, context) {
|
|
520
554
|
try {
|
|
521
555
|
const db = getAgentDb();
|
|
522
|
-
const
|
|
523
|
-
|
|
556
|
+
const writeTurn2 = db.transaction(() => {
|
|
557
|
+
const now = Date.now();
|
|
524
558
|
const result = db.prepare(`
|
|
525
559
|
INSERT OR IGNORE INTO turns (session_id, turn_number, role, content, agent, model, tool_calls, created_at)
|
|
526
560
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
527
|
-
`).run(
|
|
528
|
-
sessionId,
|
|
529
|
-
turn.turnNumber,
|
|
530
|
-
turn.role,
|
|
531
|
-
turn.content,
|
|
532
|
-
turn.agent ?? null,
|
|
533
|
-
turn.model ?? null,
|
|
534
|
-
turn.toolCalls ? JSON.stringify(turn.toolCalls) : null,
|
|
535
|
-
now
|
|
536
|
-
);
|
|
561
|
+
`).run(sessionId, turn.turnNumber, turn.role, turn.content, turn.agent ?? null, turn.model ?? null, turn.toolCalls ? JSON.stringify(turn.toolCalls) : null, now);
|
|
537
562
|
if (result.changes > 0) {
|
|
538
|
-
db.prepare("INSERT INTO turns_fts (rowid, content) VALUES (?, ?)").run(
|
|
539
|
-
result.lastInsertRowid,
|
|
540
|
-
turn.content
|
|
541
|
-
);
|
|
563
|
+
db.prepare("INSERT OR IGNORE INTO turns_fts (rowid, content) VALUES (?, ?)").run(result.lastInsertRowid, turn.content);
|
|
542
564
|
}
|
|
543
|
-
db.prepare(
|
|
544
|
-
"UPDATE sessions SET turn_count = turn_count + 1, updated_at = ? WHERE id = ?"
|
|
545
|
-
).run(now, sessionId);
|
|
565
|
+
db.prepare("UPDATE sessions SET turn_count = turn_count + 1, updated_at = ? WHERE id = ?").run(now, sessionId);
|
|
546
566
|
});
|
|
547
|
-
|
|
567
|
+
try {
|
|
568
|
+
writeTurn2();
|
|
569
|
+
return;
|
|
570
|
+
} catch (err) {
|
|
571
|
+
if (context && isRecoverableSessionConstraintError(err)) {
|
|
572
|
+
seedSessionRowForTurn(sessionId, context.project, context.filePath);
|
|
573
|
+
writeTurn2();
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
throw err;
|
|
577
|
+
}
|
|
548
578
|
} catch (err) {
|
|
549
|
-
|
|
579
|
+
const code = typeof err === "object" && err !== null && "code" in err ? String(err.code) : "unknown";
|
|
580
|
+
process.stderr.write(`[chitragupta] turn insert failed for session ${sessionId} (turn=${turn.turnNumber}, role=${turn.role}, code=${code}): ${err instanceof Error ? err.message : err}
|
|
550
581
|
`);
|
|
551
582
|
}
|
|
552
583
|
}
|
|
@@ -589,14 +620,13 @@ function saveSession(session) {
|
|
|
589
620
|
atomicRename(tmpPath, filePath);
|
|
590
621
|
cachePut(session.meta.id, session.meta.project, session);
|
|
591
622
|
} catch (err) {
|
|
592
|
-
throw new SessionError(
|
|
593
|
-
`Failed to save session ${session.meta.id} at ${filePath}: ${err.message}`
|
|
594
|
-
);
|
|
623
|
+
throw new SessionError(`Failed to save session ${session.meta.id} at ${filePath}: ${err.message}`);
|
|
595
624
|
}
|
|
596
625
|
}
|
|
597
626
|
function loadSession(id, project) {
|
|
598
627
|
const cached = cacheGet(id, project);
|
|
599
|
-
if (cached)
|
|
628
|
+
if (cached)
|
|
629
|
+
return cached;
|
|
600
630
|
const filePath = resolveSessionPath(id, project);
|
|
601
631
|
if (!fs.existsSync(filePath)) {
|
|
602
632
|
throw new SessionError(`Session not found: ${id} (project: ${project})`);
|
|
@@ -607,10 +637,9 @@ function loadSession(id, project) {
|
|
|
607
637
|
cachePut(id, project, session);
|
|
608
638
|
return session;
|
|
609
639
|
} catch (err) {
|
|
610
|
-
if (err instanceof SessionError)
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
);
|
|
640
|
+
if (err instanceof SessionError)
|
|
641
|
+
throw err;
|
|
642
|
+
throw new SessionError(`Failed to load session ${id}: ${err.message}`);
|
|
614
643
|
}
|
|
615
644
|
}
|
|
616
645
|
function listSessions(project) {
|
|
@@ -618,13 +647,9 @@ function listSessions(project) {
|
|
|
618
647
|
const db = getAgentDb();
|
|
619
648
|
let rows;
|
|
620
649
|
if (project) {
|
|
621
|
-
rows = db.prepare(
|
|
622
|
-
"SELECT * FROM sessions WHERE project = ? ORDER BY updated_at DESC"
|
|
623
|
-
).all(project);
|
|
650
|
+
rows = db.prepare("SELECT * FROM sessions WHERE project = ? ORDER BY updated_at DESC").all(project);
|
|
624
651
|
} else {
|
|
625
|
-
rows = db.prepare(
|
|
626
|
-
"SELECT * FROM sessions ORDER BY updated_at DESC"
|
|
627
|
-
).all();
|
|
652
|
+
rows = db.prepare("SELECT * FROM sessions ORDER BY updated_at DESC").all();
|
|
628
653
|
}
|
|
629
654
|
if (rows.length > 0) {
|
|
630
655
|
return rows.map(rowToSessionMeta);
|
|
@@ -649,13 +674,9 @@ function listSessionsByDateRange(startMs, endMs, project) {
|
|
|
649
674
|
const db = getAgentDb();
|
|
650
675
|
let rows;
|
|
651
676
|
if (project) {
|
|
652
|
-
rows = db.prepare(
|
|
653
|
-
"SELECT * FROM sessions WHERE project = ? AND created_at >= ? AND created_at < ? ORDER BY created_at ASC"
|
|
654
|
-
).all(project, startMs, endMs);
|
|
677
|
+
rows = db.prepare("SELECT * FROM sessions WHERE project = ? AND created_at >= ? AND created_at < ? ORDER BY created_at ASC").all(project, startMs, endMs);
|
|
655
678
|
} else {
|
|
656
|
-
rows = db.prepare(
|
|
657
|
-
"SELECT * FROM sessions WHERE created_at >= ? AND created_at < ? ORDER BY created_at ASC"
|
|
658
|
-
).all(startMs, endMs);
|
|
679
|
+
rows = db.prepare("SELECT * FROM sessions WHERE created_at >= ? AND created_at < ? ORDER BY created_at ASC").all(startMs, endMs);
|
|
659
680
|
}
|
|
660
681
|
if (rows.length > 0) {
|
|
661
682
|
return rows.map(rowToSessionMeta);
|
|
@@ -673,17 +694,13 @@ function listSessionDates(project) {
|
|
|
673
694
|
const db = getAgentDb();
|
|
674
695
|
let rows;
|
|
675
696
|
if (project) {
|
|
676
|
-
rows = db.prepare(
|
|
677
|
-
`SELECT DISTINCT date(created_at / 1000, 'unixepoch') as session_date
|
|
697
|
+
rows = db.prepare(`SELECT DISTINCT date(created_at / 1000, 'unixepoch') as session_date
|
|
678
698
|
FROM sessions WHERE project = ?
|
|
679
|
-
ORDER BY session_date DESC`
|
|
680
|
-
).all(project);
|
|
699
|
+
ORDER BY session_date DESC`).all(project);
|
|
681
700
|
} else {
|
|
682
|
-
rows = db.prepare(
|
|
683
|
-
`SELECT DISTINCT date(created_at / 1000, 'unixepoch') as session_date
|
|
701
|
+
rows = db.prepare(`SELECT DISTINCT date(created_at / 1000, 'unixepoch') as session_date
|
|
684
702
|
FROM sessions
|
|
685
|
-
ORDER BY session_date DESC`
|
|
686
|
-
).all();
|
|
703
|
+
ORDER BY session_date DESC`).all();
|
|
687
704
|
}
|
|
688
705
|
return rows.map((r) => r.session_date).filter(Boolean);
|
|
689
706
|
} catch {
|
|
@@ -698,12 +715,10 @@ function listSessionDates(project) {
|
|
|
698
715
|
function listSessionProjects() {
|
|
699
716
|
try {
|
|
700
717
|
const db = getAgentDb();
|
|
701
|
-
const rows = db.prepare(
|
|
702
|
-
`SELECT project, COUNT(*) as count, MAX(updated_at) as last_active
|
|
718
|
+
const rows = db.prepare(`SELECT project, COUNT(*) as count, MAX(updated_at) as last_active
|
|
703
719
|
FROM sessions
|
|
704
720
|
GROUP BY project
|
|
705
|
-
ORDER BY last_active DESC`
|
|
706
|
-
).all();
|
|
721
|
+
ORDER BY last_active DESC`).all();
|
|
707
722
|
return rows.map((r) => ({
|
|
708
723
|
project: r.project,
|
|
709
724
|
sessionCount: r.count,
|
|
@@ -715,11 +730,13 @@ function listSessionProjects() {
|
|
|
715
730
|
}
|
|
716
731
|
function listSessionsFromFilesystem(project) {
|
|
717
732
|
const sessionsRoot = getSessionsRoot();
|
|
718
|
-
if (!fs.existsSync(sessionsRoot))
|
|
733
|
+
if (!fs.existsSync(sessionsRoot))
|
|
734
|
+
return [];
|
|
719
735
|
const results = [];
|
|
720
736
|
if (project) {
|
|
721
737
|
const projectDir = getProjectSessionDir(project);
|
|
722
|
-
if (!fs.existsSync(projectDir))
|
|
738
|
+
if (!fs.existsSync(projectDir))
|
|
739
|
+
return [];
|
|
723
740
|
results.push(...scanDirRecursive(projectDir));
|
|
724
741
|
} else {
|
|
725
742
|
const projectDirs = fs.readdirSync(sessionsRoot, { withFileTypes: true });
|
|
@@ -814,7 +831,7 @@ function addTurn(sessionId, project, turn) {
|
|
|
814
831
|
${turnMd}
|
|
815
832
|
`, "utf-8");
|
|
816
833
|
cacheInvalidate(sessionId, project);
|
|
817
|
-
insertTurnToDb(sessionId, turn);
|
|
834
|
+
insertTurnToDb(sessionId, turn, { project, filePath });
|
|
818
835
|
}).catch((err) => {
|
|
819
836
|
throw err;
|
|
820
837
|
}).finally(() => {
|
|
@@ -828,9 +845,7 @@ ${turnMd}
|
|
|
828
845
|
function listTurnsWithTimestamps(sessionId, project) {
|
|
829
846
|
try {
|
|
830
847
|
const db = getAgentDb();
|
|
831
|
-
const rows = db.prepare(
|
|
832
|
-
"SELECT turn_number, role, content, agent, model, tool_calls, created_at FROM turns WHERE session_id = ? ORDER BY turn_number ASC"
|
|
833
|
-
).all(sessionId);
|
|
848
|
+
const rows = db.prepare("SELECT turn_number, role, content, agent, model, tool_calls, created_at FROM turns WHERE session_id = ? ORDER BY turn_number ASC").all(sessionId);
|
|
834
849
|
if (rows.length > 0) {
|
|
835
850
|
return rows.map((row) => ({
|
|
836
851
|
turnNumber: row.turn_number,
|
|
@@ -877,7 +892,8 @@ function updateSessionMeta(sessionId, updates) {
|
|
|
877
892
|
sets.push("tags = @tags");
|
|
878
893
|
params.tags = JSON.stringify(updates.tags);
|
|
879
894
|
}
|
|
880
|
-
if (sets.length === 0)
|
|
895
|
+
if (sets.length === 0)
|
|
896
|
+
return;
|
|
881
897
|
sets.push("updated_at = @updated_at");
|
|
882
898
|
params.updated_at = Date.now();
|
|
883
899
|
db.prepare(`UPDATE sessions SET ${sets.join(", ")} WHERE id = @id`).run(params);
|
|
@@ -910,7 +926,8 @@ function findSessionByMetadata(key, value, project) {
|
|
|
910
926
|
function migrateExistingSessions(project) {
|
|
911
927
|
const db = getAgentDb();
|
|
912
928
|
const sessionsRoot = getSessionsRoot();
|
|
913
|
-
if (!fs.existsSync(sessionsRoot))
|
|
929
|
+
if (!fs.existsSync(sessionsRoot))
|
|
930
|
+
return { migrated: 0, skipped: 0 };
|
|
914
931
|
let migrated = 0;
|
|
915
932
|
let skipped = 0;
|
|
916
933
|
const dirs = project ? [getProjectSessionDir(project)] : fs.readdirSync(sessionsRoot, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => path.join(sessionsRoot, e.name));
|
|
@@ -922,9 +939,7 @@ function migrateExistingSessions(project) {
|
|
|
922
939
|
INSERT OR IGNORE INTO turns (session_id, turn_number, role, content, agent, model, tool_calls, created_at)
|
|
923
940
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
924
941
|
`);
|
|
925
|
-
const insertFts = db.prepare(
|
|
926
|
-
"INSERT INTO turns_fts (rowid, content) VALUES (?, ?)"
|
|
927
|
-
);
|
|
942
|
+
const insertFts = db.prepare("INSERT INTO turns_fts (rowid, content) VALUES (?, ?)");
|
|
928
943
|
const migrateFile = (mdPath, relativePath) => {
|
|
929
944
|
try {
|
|
930
945
|
const content = fs.readFileSync(mdPath, "utf-8");
|
|
@@ -938,16 +953,7 @@ function migrateExistingSessions(project) {
|
|
|
938
953
|
row.turn_count = session.turns.length;
|
|
939
954
|
insertSession.run(row);
|
|
940
955
|
for (const turn of session.turns) {
|
|
941
|
-
const result = insertTurn.run(
|
|
942
|
-
session.meta.id,
|
|
943
|
-
turn.turnNumber,
|
|
944
|
-
turn.role,
|
|
945
|
-
turn.content,
|
|
946
|
-
turn.agent ?? null,
|
|
947
|
-
turn.model ?? null,
|
|
948
|
-
turn.toolCalls ? JSON.stringify(turn.toolCalls) : null,
|
|
949
|
-
new Date(session.meta.created).getTime()
|
|
950
|
-
);
|
|
956
|
+
const result = insertTurn.run(session.meta.id, turn.turnNumber, turn.role, turn.content, turn.agent ?? null, turn.model ?? null, turn.toolCalls ? JSON.stringify(turn.toolCalls) : null, new Date(session.meta.created).getTime());
|
|
951
957
|
if (result.changes > 0) {
|
|
952
958
|
insertFts.run(result.lastInsertRowid, turn.content);
|
|
953
959
|
}
|
|
@@ -959,7 +965,8 @@ function migrateExistingSessions(project) {
|
|
|
959
965
|
};
|
|
960
966
|
const runMigration = db.transaction(() => {
|
|
961
967
|
for (const dir of dirs) {
|
|
962
|
-
if (!fs.existsSync(dir))
|
|
968
|
+
if (!fs.existsSync(dir))
|
|
969
|
+
continue;
|
|
963
970
|
walkMdFiles(dir, sessionsRoot, migrateFile);
|
|
964
971
|
}
|
|
965
972
|
});
|
|
@@ -1005,4 +1012,4 @@ export {
|
|
|
1005
1012
|
findSessionByMetadata,
|
|
1006
1013
|
migrateExistingSessions
|
|
1007
1014
|
};
|
|
1008
|
-
//# sourceMappingURL=chunk-
|
|
1015
|
+
//# sourceMappingURL=chunk-ZYY6N3SP.js.map
|
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
extractSummaryText,
|
|
5
5
|
indexConsolidationSummary,
|
|
6
6
|
searchConsolidationSummaries
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-JZTFJE7M.js";
|
|
8
|
+
import "./chunk-D46QTN3G.js";
|
|
9
|
+
import "./chunk-ZYY6N3SP.js";
|
|
10
|
+
import "./chunk-A3HOZBC5.js";
|
|
11
|
+
import "./chunk-V2ZIKDN4.js";
|
|
12
|
+
import "./chunk-67DXWEKG.js";
|
|
13
|
+
import "./chunk-2OBLQJYJ.js";
|
|
14
14
|
import "./chunk-IGKYKEKT.js";
|
|
15
15
|
export {
|
|
16
16
|
_resetConsolidationIndexer,
|
|
@@ -19,4 +19,4 @@ export {
|
|
|
19
19
|
indexConsolidationSummary,
|
|
20
20
|
searchConsolidationSummaries
|
|
21
21
|
};
|
|
22
|
-
//# sourceMappingURL=consolidation-indexer-
|
|
22
|
+
//# sourceMappingURL=consolidation-indexer-VIWOP6VO.js.map
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
consolidateDay,
|
|
3
|
+
eventIcon,
|
|
4
|
+
generateDayMarkdown,
|
|
3
5
|
getDayFilePath,
|
|
4
6
|
getDaysRoot,
|
|
5
7
|
getUnconsolidatedDates,
|
|
@@ -7,12 +9,14 @@ import {
|
|
|
7
9
|
listDayFiles,
|
|
8
10
|
readDayFile,
|
|
9
11
|
searchDayFiles
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-F6RNEGFX.js";
|
|
13
|
+
import "./chunk-A3HOZBC5.js";
|
|
14
|
+
import "./chunk-2OBLQJYJ.js";
|
|
13
15
|
import "./chunk-IGKYKEKT.js";
|
|
14
16
|
export {
|
|
15
17
|
consolidateDay,
|
|
18
|
+
eventIcon,
|
|
19
|
+
generateDayMarkdown,
|
|
16
20
|
getDayFilePath,
|
|
17
21
|
getDaysRoot,
|
|
18
22
|
getUnconsolidatedDates,
|
|
@@ -21,4 +25,4 @@ export {
|
|
|
21
25
|
readDayFile,
|
|
22
26
|
searchDayFiles
|
|
23
27
|
};
|
|
24
|
-
//# sourceMappingURL=day-consolidation-
|
|
28
|
+
//# sourceMappingURL=day-consolidation-HMHSXIOM.js.map
|
|
@@ -41,13 +41,13 @@ import {
|
|
|
41
41
|
sinkhornAccelerated,
|
|
42
42
|
sinkhornKnopp,
|
|
43
43
|
writeCrossMachineSnapshot
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-VCUJES75.js";
|
|
45
45
|
import {
|
|
46
46
|
backfillConsolidationIndices,
|
|
47
47
|
extractSummaryText,
|
|
48
48
|
indexConsolidationSummary,
|
|
49
49
|
searchConsolidationSummaries
|
|
50
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-JZTFJE7M.js";
|
|
51
51
|
import {
|
|
52
52
|
FactExtractor,
|
|
53
53
|
consolidateDay,
|
|
@@ -62,30 +62,30 @@ import {
|
|
|
62
62
|
listDayFiles,
|
|
63
63
|
readDayFile,
|
|
64
64
|
searchDayFiles
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-F6RNEGFX.js";
|
|
66
66
|
import {
|
|
67
67
|
HybridSearchEngine,
|
|
68
68
|
HybridWeightLearner,
|
|
69
69
|
PRAMANA_RELIABILITY,
|
|
70
70
|
shouldRetrieve
|
|
71
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-QV4GPIPT.js";
|
|
72
72
|
import {
|
|
73
73
|
VasanaEngine
|
|
74
|
-
} from "./chunk-
|
|
74
|
+
} from "./chunk-W4PVGBUH.js";
|
|
75
75
|
import {
|
|
76
76
|
hierarchicalTemporalSearch
|
|
77
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-7XV5ISV7.js";
|
|
78
78
|
import {
|
|
79
79
|
searchMemory,
|
|
80
80
|
searchSessions
|
|
81
|
-
} from "./chunk-
|
|
81
|
+
} from "./chunk-3AYSJ7WB.js";
|
|
82
82
|
import {
|
|
83
83
|
appendMemory,
|
|
84
84
|
deleteMemory,
|
|
85
85
|
getMemory,
|
|
86
86
|
listMemoryScopes,
|
|
87
87
|
updateMemory
|
|
88
|
-
} from "./chunk-
|
|
88
|
+
} from "./chunk-7AYYXHYZ.js";
|
|
89
89
|
import {
|
|
90
90
|
GraphRAGEngine,
|
|
91
91
|
IncrementalPageRank,
|
|
@@ -104,7 +104,7 @@ import {
|
|
|
104
104
|
queryEdgesAtTime,
|
|
105
105
|
supersedEdge,
|
|
106
106
|
temporalDecay
|
|
107
|
-
} from "./chunk-
|
|
107
|
+
} from "./chunk-LJUEMPLG.js";
|
|
108
108
|
import {
|
|
109
109
|
PRESERVATION_RATIOS,
|
|
110
110
|
RecallEngine,
|
|
@@ -116,7 +116,7 @@ import {
|
|
|
116
116
|
configureRecallScoring,
|
|
117
117
|
migrateEmbeddingsJson,
|
|
118
118
|
vectorToBlob
|
|
119
|
-
} from "./chunk-
|
|
119
|
+
} from "./chunk-D46QTN3G.js";
|
|
120
120
|
import {
|
|
121
121
|
addTurn,
|
|
122
122
|
createSession,
|
|
@@ -136,25 +136,25 @@ import {
|
|
|
136
136
|
updateSessionMeta,
|
|
137
137
|
writeSessionMarkdown,
|
|
138
138
|
writeTurnMarkdown
|
|
139
|
-
} from "./chunk-
|
|
139
|
+
} from "./chunk-ZYY6N3SP.js";
|
|
140
140
|
import {
|
|
141
141
|
EmbeddingService,
|
|
142
142
|
estimateTokens,
|
|
143
143
|
fallbackEmbedding
|
|
144
|
-
} from "./chunk-
|
|
144
|
+
} from "./chunk-A3HOZBC5.js";
|
|
145
145
|
import {
|
|
146
146
|
PeriodicConsolidation
|
|
147
|
-
} from "./chunk-
|
|
147
|
+
} from "./chunk-Z576WVLG.js";
|
|
148
148
|
import {
|
|
149
149
|
initAgentSchema,
|
|
150
150
|
initAllSchemas,
|
|
151
151
|
initGraphSchema,
|
|
152
152
|
initVectorsSchema
|
|
153
|
-
} from "./chunk-
|
|
153
|
+
} from "./chunk-V2ZIKDN4.js";
|
|
154
154
|
import {
|
|
155
155
|
DatabaseManager
|
|
156
|
-
} from "./chunk-
|
|
157
|
-
import "./chunk-
|
|
156
|
+
} from "./chunk-67DXWEKG.js";
|
|
157
|
+
import "./chunk-2OBLQJYJ.js";
|
|
158
158
|
import "./chunk-IGKYKEKT.js";
|
|
159
159
|
export {
|
|
160
160
|
AdaptiveScorer,
|
|
@@ -284,4 +284,4 @@ export {
|
|
|
284
284
|
writeSessionMarkdown,
|
|
285
285
|
writeTurnMarkdown
|
|
286
286
|
};
|
|
287
|
-
//# sourceMappingURL=
|
|
287
|
+
//# sourceMappingURL=dist-CY5NX2IK.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GraphRAGEngine,
|
|
3
|
+
migrateGraphJson
|
|
4
|
+
} from "./chunk-LJUEMPLG.js";
|
|
5
|
+
import "./chunk-A3HOZBC5.js";
|
|
6
|
+
import "./chunk-V2ZIKDN4.js";
|
|
7
|
+
import "./chunk-67DXWEKG.js";
|
|
8
|
+
import "./chunk-2OBLQJYJ.js";
|
|
9
|
+
import "./chunk-IGKYKEKT.js";
|
|
10
|
+
export {
|
|
11
|
+
GraphRAGEngine,
|
|
12
|
+
migrateGraphJson
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=graphrag-T2QWNX57.js.map
|
package/chunks/{hierarchical-temporal-search-ETXYYJZK.js → hierarchical-temporal-search-U6DG74IR.js}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
hierarchicalTemporalSearch
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7XV5ISV7.js";
|
|
4
4
|
import "./chunk-IGKYKEKT.js";
|
|
5
5
|
export {
|
|
6
6
|
hierarchicalTemporalSearch
|
|
7
7
|
};
|
|
8
|
-
//# sourceMappingURL=hierarchical-temporal-search-
|
|
8
|
+
//# sourceMappingURL=hierarchical-temporal-search-U6DG74IR.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HybridSearchEngine,
|
|
3
|
+
HybridWeightLearner,
|
|
4
|
+
PRAMANA_RELIABILITY,
|
|
5
|
+
shouldRetrieve
|
|
6
|
+
} from "./chunk-QV4GPIPT.js";
|
|
7
|
+
import "./chunk-3AYSJ7WB.js";
|
|
8
|
+
import "./chunk-7AYYXHYZ.js";
|
|
9
|
+
import "./chunk-ZYY6N3SP.js";
|
|
10
|
+
import "./chunk-V2ZIKDN4.js";
|
|
11
|
+
import "./chunk-67DXWEKG.js";
|
|
12
|
+
import "./chunk-2OBLQJYJ.js";
|
|
13
|
+
import "./chunk-IGKYKEKT.js";
|
|
14
|
+
export {
|
|
15
|
+
HybridSearchEngine,
|
|
16
|
+
HybridWeightLearner,
|
|
17
|
+
PRAMANA_RELIABILITY,
|
|
18
|
+
shouldRetrieve
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=hybrid-search-BYTXCOXP.js.map
|