@yugenlab/vaayu 0.1.10 → 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-O4KV7TFP.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-JGI4SDWS.js → chunk-7XV5ISV7.js} +7 -5
- package/chunks/{chunk-JAWZ7ANC.js → chunk-A3HOZBC5.js} +11 -7
- package/chunks/{chunk-VJHNE47S.js → chunk-D46QTN3G.js} +63 -82
- package/chunks/{chunk-PRXQW76U.js → chunk-EG37M4QL.js} +17 -6
- package/chunks/{chunk-77725AR7.js → chunk-F6RNEGFX.js} +82 -53
- package/chunks/{chunk-MJ74G5RB.js → chunk-G2QREGXK.js} +2 -2
- package/chunks/{chunk-AS3DJFY3.js → chunk-JZTFJE7M.js} +39 -39
- package/chunks/{chunk-OT4G2L46.js → chunk-LJUEMPLG.js} +202 -154
- package/chunks/{chunk-C76USAC5.js → chunk-QFGAB4XD.js} +13 -5
- package/chunks/{chunk-M7THR63C.js → chunk-QV4GPIPT.js} +74 -65
- package/chunks/{chunk-YJRXLRTE.js → chunk-V2ZIKDN4.js} +9 -8
- package/chunks/{chunk-AGK3A7R7.js → chunk-VCUJES75.js} +791 -677
- package/chunks/{chunk-N22M7D4P.js → chunk-W4PVGBUH.js} +86 -97
- package/chunks/{chunk-TND3MU4Z.js → chunk-Z576WVLG.js} +74 -66
- package/chunks/{chunk-HIYHTWFW.js → chunk-ZYY6N3SP.js} +90 -118
- package/chunks/{consolidation-indexer-VKQ6DNU3.js → consolidation-indexer-VIWOP6VO.js} +8 -8
- package/chunks/{day-consolidation-BH3QU2SZ.js → day-consolidation-HMHSXIOM.js} +4 -4
- package/chunks/{src-Y3TGMINC.js → dist-CY5NX2IK.js} +17 -17
- package/chunks/graphrag-T2QWNX57.js +14 -0
- package/chunks/{hierarchical-temporal-search-PVHVA3NZ.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-ZNL4DJ2L.js → recall-LNRQVATQ.js} +7 -7
- package/chunks/search-BIODUW2P.js +19 -0
- package/chunks/{session-store-3BRPGC6P.js → session-store-O3TS7DUY.js} +5 -5
- package/chunks/{sqlite-DHUQGPR5.js → sqlite-7BC4DJTN.js} +2 -2
- package/chunks/{vasana-engine-MU25OQ23.js → vasana-engine-BJFHJVGM.js} +4 -4
- package/gateway.js +31592 -24973
- package/package.json +1 -1
- package/pair-cli.js +1 -1
- package/chunks/graphrag-D7OXWAWD.js +0 -14
- package/chunks/hybrid-search-G2NAJKJ7.js +0 -20
- package/chunks/periodic-consolidation-LMYMNS4Q.js +0 -11
- package/chunks/search-35JMSGUT.js +0 -19
|
@@ -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
|
|
@@ -2,17 +2,17 @@ import {
|
|
|
2
2
|
EmbeddingService,
|
|
3
3
|
cosineSimilarity,
|
|
4
4
|
fallbackEmbedding
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-A3HOZBC5.js";
|
|
6
6
|
import {
|
|
7
7
|
SessionError,
|
|
8
8
|
getChitraguptaHome
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-2OBLQJYJ.js";
|
|
10
10
|
|
|
11
|
-
// ../chitragupta/packages/smriti/
|
|
11
|
+
// ../chitragupta/packages/smriti/dist/day-consolidation.js
|
|
12
12
|
import fs2 from "fs";
|
|
13
13
|
import path2 from "path";
|
|
14
14
|
|
|
15
|
-
// ../chitragupta/packages/smriti/
|
|
15
|
+
// ../chitragupta/packages/smriti/dist/event-extractor-strategies.js
|
|
16
16
|
var DOMAIN_EXTRACTOR_MAP = {
|
|
17
17
|
planning: "discussion",
|
|
18
18
|
learning: "discussion",
|
|
@@ -171,9 +171,7 @@ function extractFromDiscussionAssistant(turn, timestamp, sessionId, provider) {
|
|
|
171
171
|
});
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
|
-
const optionLines = lines.filter(
|
|
175
|
-
(l) => /^(?:\d+\.|[-*]|\*\*Option|Option [A-C])/i.test(l.trim())
|
|
176
|
-
);
|
|
174
|
+
const optionLines = lines.filter((l) => /^(?:\d+\.|[-*]|\*\*Option|Option [A-C])/i.test(l.trim()));
|
|
177
175
|
if (optionLines.length >= 2) {
|
|
178
176
|
const summary = optionLines.slice(0, 4).map((l) => l.trim().slice(0, 100)).join("; ");
|
|
179
177
|
events.push({
|
|
@@ -204,7 +202,8 @@ function extractFromDiscussionAssistant(turn, timestamp, sessionId, provider) {
|
|
|
204
202
|
}
|
|
205
203
|
function extractTopic(content) {
|
|
206
204
|
const firstLine = content.split("\n")[0].trim();
|
|
207
|
-
if (firstLine.length < 5 || firstLine.length > 200)
|
|
205
|
+
if (firstLine.length < 5 || firstLine.length > 200)
|
|
206
|
+
return null;
|
|
208
207
|
const cleaned = firstLine.replace(/^(?:hey|hi|hello|ok|okay|so|well|please|pls|can you|could you)\s+/i, "").trim();
|
|
209
208
|
return cleaned.length > 5 ? cleaned.slice(0, 100) : null;
|
|
210
209
|
}
|
|
@@ -212,7 +211,8 @@ function deduplicateEvents(events) {
|
|
|
212
211
|
const seen = /* @__PURE__ */ new Set();
|
|
213
212
|
return events.filter((event) => {
|
|
214
213
|
const key = `${event.type}:${event.summary.toLowerCase().replace(/[^\w\s]/g, "").trim().slice(0, 50)}`;
|
|
215
|
-
if (seen.has(key))
|
|
214
|
+
if (seen.has(key))
|
|
215
|
+
return false;
|
|
216
216
|
seen.add(key);
|
|
217
217
|
return true;
|
|
218
218
|
});
|
|
@@ -246,25 +246,31 @@ function generateNarrative(sessionType, events, meta, provider) {
|
|
|
246
246
|
const errors = events.filter((e) => e.type === "error");
|
|
247
247
|
const commits = events.filter((e) => e.type === "commit");
|
|
248
248
|
const decisions = events.filter((e) => e.type === "decision");
|
|
249
|
-
if (decisions.length > 0)
|
|
249
|
+
if (decisions.length > 0)
|
|
250
|
+
parts.push(decisions[0].summary);
|
|
250
251
|
parts.push(`${actions.length} actions`);
|
|
251
|
-
if (errors.length > 0)
|
|
252
|
-
|
|
252
|
+
if (errors.length > 0)
|
|
253
|
+
parts.push(`${errors.length} errors`);
|
|
254
|
+
if (commits.length > 0)
|
|
255
|
+
parts.push(`${commits.length} commits`);
|
|
253
256
|
} else if (strategy === "discussion") {
|
|
254
257
|
const topics = events.filter((e) => e.type === "topic");
|
|
255
258
|
const decisions = events.filter((e) => e.type === "decision");
|
|
256
|
-
if (topics.length > 0)
|
|
257
|
-
|
|
259
|
+
if (topics.length > 0)
|
|
260
|
+
parts.push(`Discussed: ${topics.map((t) => t.summary).slice(0, 3).join(", ")}`);
|
|
261
|
+
if (decisions.length > 0)
|
|
262
|
+
parts.push(`${decisions.length} decisions`);
|
|
258
263
|
} else if (strategy === "personal") {
|
|
259
264
|
const facts = events.filter((e) => e.type === "fact" || e.type === "preference");
|
|
260
|
-
if (facts.length > 0)
|
|
265
|
+
if (facts.length > 0)
|
|
266
|
+
parts.push(facts.map((f) => f.summary).join("; "));
|
|
261
267
|
} else {
|
|
262
268
|
parts.push(`${events.length} events`);
|
|
263
269
|
}
|
|
264
270
|
return parts.join(" \u2014 ");
|
|
265
271
|
}
|
|
266
272
|
|
|
267
|
-
// ../chitragupta/packages/smriti/
|
|
273
|
+
// ../chitragupta/packages/smriti/dist/event-extractor.js
|
|
268
274
|
var DOMAIN_SIGNALS = {
|
|
269
275
|
planning: [
|
|
270
276
|
/\b(?:plan for|roadmap|milestone|timeline|schedule|deadline|sprint|backlog|prioriti[sz]e)\b/i,
|
|
@@ -327,12 +333,14 @@ function scoreDomainSignals(turns) {
|
|
|
327
333
|
groupsMatched++;
|
|
328
334
|
}
|
|
329
335
|
}
|
|
330
|
-
if (groupsMatched > 0)
|
|
336
|
+
if (groupsMatched > 0)
|
|
337
|
+
scores.set(domain, groupsMatched);
|
|
331
338
|
}
|
|
332
339
|
return scores;
|
|
333
340
|
}
|
|
334
341
|
function detectSessionType(turns) {
|
|
335
|
-
if (turns.length === 0)
|
|
342
|
+
if (turns.length === 0)
|
|
343
|
+
return "personal";
|
|
336
344
|
let toolTurns = 0;
|
|
337
345
|
let textTurns = 0;
|
|
338
346
|
let totalUserLength = 0;
|
|
@@ -361,9 +369,11 @@ function detectSessionType(turns) {
|
|
|
361
369
|
} else {
|
|
362
370
|
coreType = "mixed";
|
|
363
371
|
}
|
|
364
|
-
if (coreType === "coding")
|
|
372
|
+
if (coreType === "coding")
|
|
373
|
+
return "coding";
|
|
365
374
|
const domainScores = scoreDomainSignals(turns);
|
|
366
|
-
if (domainScores.size === 0)
|
|
375
|
+
if (domainScores.size === 0)
|
|
376
|
+
return coreType;
|
|
367
377
|
let topDomain = null;
|
|
368
378
|
let topScore = 0;
|
|
369
379
|
for (const [domain, score] of domainScores) {
|
|
@@ -426,7 +436,7 @@ function extractEventChain(meta, turns) {
|
|
|
426
436
|
return { sessionType, events: deduped, narrative, topics, meta };
|
|
427
437
|
}
|
|
428
438
|
|
|
429
|
-
// ../chitragupta/packages/smriti/
|
|
439
|
+
// ../chitragupta/packages/smriti/dist/fact-extractor.js
|
|
430
440
|
var DEFAULT_CONFIG = {
|
|
431
441
|
minConfidence: 0.5,
|
|
432
442
|
useVectors: true,
|
|
@@ -525,7 +535,8 @@ var FactExtractor = class {
|
|
|
525
535
|
* Initialize vector templates (lazy, on first use).
|
|
526
536
|
*/
|
|
527
537
|
async ensureInitialized() {
|
|
528
|
-
if (this.initialized)
|
|
538
|
+
if (this.initialized)
|
|
539
|
+
return;
|
|
529
540
|
if (!this.config.useVectors) {
|
|
530
541
|
this.initialized = true;
|
|
531
542
|
return;
|
|
@@ -549,7 +560,8 @@ var FactExtractor = class {
|
|
|
549
560
|
async extract(text) {
|
|
550
561
|
await this.ensureInitialized();
|
|
551
562
|
const facts = [];
|
|
552
|
-
if (text.length < 5 || text.length > 5e3)
|
|
563
|
+
if (text.length < 5 || text.length > 5e3)
|
|
564
|
+
return facts;
|
|
553
565
|
for (const rule of FACT_PATTERNS) {
|
|
554
566
|
for (const pattern of rule.patterns) {
|
|
555
567
|
const match = text.match(pattern);
|
|
@@ -574,7 +586,8 @@ var FactExtractor = class {
|
|
|
574
586
|
let bestTemplate = null;
|
|
575
587
|
for (const tmpl of VECTOR_TEMPLATES) {
|
|
576
588
|
const tmplEmbedding = this.templateEmbeddings.get(tmpl.template);
|
|
577
|
-
if (!tmplEmbedding)
|
|
589
|
+
if (!tmplEmbedding)
|
|
590
|
+
continue;
|
|
578
591
|
const score = cosineSimilarity(inputEmbedding, tmplEmbedding);
|
|
579
592
|
if (score > bestScore) {
|
|
580
593
|
bestScore = score;
|
|
@@ -608,14 +621,17 @@ var FactExtractor = class {
|
|
|
608
621
|
*/
|
|
609
622
|
async extractAndSave(text, scope, projectScope) {
|
|
610
623
|
const facts = await this.extract(text);
|
|
611
|
-
if (facts.length === 0)
|
|
612
|
-
|
|
624
|
+
if (facts.length === 0)
|
|
625
|
+
return [];
|
|
626
|
+
const { appendMemory, getMemory } = await import("./memory-store-LEERUQGL.js");
|
|
613
627
|
const globalScope = scope ?? { type: "global" };
|
|
614
628
|
const existingMemory = getMemory(globalScope).toLowerCase();
|
|
615
629
|
for (const fact of facts) {
|
|
616
630
|
const dedupeKey = `${fact.category}:${fact.fact.toLowerCase().slice(0, 50)}`;
|
|
617
|
-
if (this.recentFacts.has(dedupeKey))
|
|
618
|
-
|
|
631
|
+
if (this.recentFacts.has(dedupeKey))
|
|
632
|
+
continue;
|
|
633
|
+
if (existingMemory.includes(fact.fact.toLowerCase().slice(0, 30)))
|
|
634
|
+
continue;
|
|
619
635
|
const entry = `[${fact.category}] ${fact.fact}`;
|
|
620
636
|
if (fact.category === "preference" && projectScope) {
|
|
621
637
|
await appendMemory(projectScope, entry);
|
|
@@ -638,7 +654,8 @@ var FactExtractor = class {
|
|
|
638
654
|
};
|
|
639
655
|
function normalizeFact(category, raw) {
|
|
640
656
|
const cleaned = raw.replace(/[.!?,;:]+$/, "").trim();
|
|
641
|
-
if (cleaned.length < 2)
|
|
657
|
+
if (cleaned.length < 2)
|
|
658
|
+
return null;
|
|
642
659
|
switch (category) {
|
|
643
660
|
case "identity":
|
|
644
661
|
return `Name: ${capitalize(cleaned)}`;
|
|
@@ -669,7 +686,7 @@ function getFactExtractor(config) {
|
|
|
669
686
|
return _instance;
|
|
670
687
|
}
|
|
671
688
|
|
|
672
|
-
// ../chitragupta/packages/smriti/
|
|
689
|
+
// ../chitragupta/packages/smriti/dist/day-consolidation-renderer.js
|
|
673
690
|
function generateDayMarkdown(date, projectMap, sessionCount, totalTurns, facts) {
|
|
674
691
|
const lines = [];
|
|
675
692
|
const dayName = (/* @__PURE__ */ new Date(`${date}T12:00:00Z`)).toLocaleDateString("en-US", { weekday: "long" });
|
|
@@ -697,7 +714,8 @@ function renderProjectSection(lines, activity) {
|
|
|
697
714
|
lines.push(`## Project: ${activity.project}`);
|
|
698
715
|
lines.push("");
|
|
699
716
|
const meta = [];
|
|
700
|
-
if (activity.branch)
|
|
717
|
+
if (activity.branch)
|
|
718
|
+
meta.push(`**Branch**: ${activity.branch}`);
|
|
701
719
|
meta.push(`**Providers**: ${[...activity.providers].join(", ")}`);
|
|
702
720
|
meta.push(`**Sessions**: ${activity.sessions.length}`);
|
|
703
721
|
if (activity.filesModified.size > 0) {
|
|
@@ -736,9 +754,7 @@ function renderSessionSection(lines, session, chain, activity) {
|
|
|
736
754
|
lines.push(`**Topics**: ${chain.topics.slice(0, 5).join(", ")}`);
|
|
737
755
|
lines.push("");
|
|
738
756
|
}
|
|
739
|
-
const keyEvents = chain.events.filter(
|
|
740
|
-
(e) => e.type === "decision" || e.type === "error" || e.type === "commit" || e.type === "fact" || e.type === "preference"
|
|
741
|
-
);
|
|
757
|
+
const keyEvents = chain.events.filter((e) => e.type === "decision" || e.type === "error" || e.type === "commit" || e.type === "fact" || e.type === "preference");
|
|
742
758
|
if (keyEvents.length > 0) {
|
|
743
759
|
for (const event of keyEvents.slice(0, 10)) {
|
|
744
760
|
const icon = eventIcon(event.type);
|
|
@@ -791,30 +807,35 @@ function eventIcon(type) {
|
|
|
791
807
|
}
|
|
792
808
|
}
|
|
793
809
|
|
|
794
|
-
// ../chitragupta/packages/smriti/
|
|
810
|
+
// ../chitragupta/packages/smriti/dist/day-consolidation-query.js
|
|
795
811
|
import fs from "fs";
|
|
796
812
|
import path from "path";
|
|
797
813
|
function readDayFile(date) {
|
|
798
814
|
const dayPath = getDayFilePath(date);
|
|
799
|
-
if (!fs.existsSync(dayPath))
|
|
815
|
+
if (!fs.existsSync(dayPath))
|
|
816
|
+
return null;
|
|
800
817
|
return fs.readFileSync(dayPath, "utf-8");
|
|
801
818
|
}
|
|
802
819
|
function listDayFiles() {
|
|
803
820
|
const daysRoot = getDaysRoot();
|
|
804
|
-
if (!fs.existsSync(daysRoot))
|
|
821
|
+
if (!fs.existsSync(daysRoot))
|
|
822
|
+
return [];
|
|
805
823
|
const dates = [];
|
|
806
824
|
try {
|
|
807
825
|
const years = fs.readdirSync(daysRoot, { withFileTypes: true });
|
|
808
826
|
for (const year of years) {
|
|
809
|
-
if (!year.isDirectory())
|
|
827
|
+
if (!year.isDirectory())
|
|
828
|
+
continue;
|
|
810
829
|
const yearPath = path.join(daysRoot, year.name);
|
|
811
830
|
const months = fs.readdirSync(yearPath, { withFileTypes: true });
|
|
812
831
|
for (const month of months) {
|
|
813
|
-
if (!month.isDirectory())
|
|
832
|
+
if (!month.isDirectory())
|
|
833
|
+
continue;
|
|
814
834
|
const monthPath = path.join(yearPath, month.name);
|
|
815
835
|
const days = fs.readdirSync(monthPath);
|
|
816
836
|
for (const day of days) {
|
|
817
|
-
if (!day.endsWith(".md"))
|
|
837
|
+
if (!day.endsWith(".md"))
|
|
838
|
+
continue;
|
|
818
839
|
const dd = day.replace(".md", "");
|
|
819
840
|
dates.push(`${year.name}-${month.name}-${dd}`);
|
|
820
841
|
}
|
|
@@ -830,9 +851,11 @@ function searchDayFiles(query, options) {
|
|
|
830
851
|
const results = [];
|
|
831
852
|
const queryLower = query.toLowerCase();
|
|
832
853
|
for (const date of dates) {
|
|
833
|
-
if (results.length >= limit)
|
|
854
|
+
if (results.length >= limit)
|
|
855
|
+
break;
|
|
834
856
|
const content = readDayFile(date);
|
|
835
|
-
if (!content)
|
|
857
|
+
if (!content)
|
|
858
|
+
continue;
|
|
836
859
|
const lines = content.split("\n");
|
|
837
860
|
const matches = [];
|
|
838
861
|
for (let i = 0; i < lines.length; i++) {
|
|
@@ -850,11 +873,12 @@ function isDayConsolidated(date) {
|
|
|
850
873
|
return fs.existsSync(getDayFilePath(date));
|
|
851
874
|
}
|
|
852
875
|
async function getUnconsolidatedDates(limit) {
|
|
853
|
-
const { listSessionDates } = await import("./session-store-
|
|
876
|
+
const { listSessionDates } = await import("./session-store-O3TS7DUY.js");
|
|
854
877
|
const sessionDates = listSessionDates();
|
|
855
878
|
const unconsolidated = [];
|
|
856
879
|
for (const date of sessionDates) {
|
|
857
|
-
if (unconsolidated.length >= (limit ?? 30))
|
|
880
|
+
if (unconsolidated.length >= (limit ?? 30))
|
|
881
|
+
break;
|
|
858
882
|
if (!isDayConsolidated(date)) {
|
|
859
883
|
unconsolidated.push(date);
|
|
860
884
|
}
|
|
@@ -862,13 +886,14 @@ async function getUnconsolidatedDates(limit) {
|
|
|
862
886
|
return unconsolidated;
|
|
863
887
|
}
|
|
864
888
|
|
|
865
|
-
// ../chitragupta/packages/smriti/
|
|
889
|
+
// ../chitragupta/packages/smriti/dist/day-consolidation.js
|
|
866
890
|
function getDaysRoot() {
|
|
867
891
|
return path2.join(getChitraguptaHome(), "days");
|
|
868
892
|
}
|
|
869
893
|
function getDayFilePath(date) {
|
|
870
894
|
const match = date.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
871
|
-
if (!match)
|
|
895
|
+
if (!match)
|
|
896
|
+
throw new SessionError(`Invalid date: ${date}. Expected YYYY-MM-DD.`);
|
|
872
897
|
return path2.join(getDaysRoot(), match[1], match[2], `${match[3]}.md`);
|
|
873
898
|
}
|
|
874
899
|
async function consolidateDay(date, options) {
|
|
@@ -891,7 +916,7 @@ async function consolidateDay(date, options) {
|
|
|
891
916
|
if (options?.loadSessions) {
|
|
892
917
|
sessions = await options.loadSessions(date);
|
|
893
918
|
} else {
|
|
894
|
-
const { listSessionsByDate, listTurnsWithTimestamps, loadSession } = await import("./session-store-
|
|
919
|
+
const { listSessionsByDate, listTurnsWithTimestamps, loadSession } = await import("./session-store-O3TS7DUY.js");
|
|
895
920
|
const metas = listSessionsByDate(date);
|
|
896
921
|
sessions = metas.map((meta) => {
|
|
897
922
|
try {
|
|
@@ -944,7 +969,8 @@ async function consolidateDay(date, options) {
|
|
|
944
969
|
activity.sessions.push(meta);
|
|
945
970
|
const provider = meta.metadata?.provider ?? meta.agent ?? "unknown";
|
|
946
971
|
activity.providers.add(provider);
|
|
947
|
-
if (meta.branch)
|
|
972
|
+
if (meta.branch)
|
|
973
|
+
activity.branch = meta.branch;
|
|
948
974
|
const eventChain = extractEventChain(meta, turns);
|
|
949
975
|
activity.eventChains.push(eventChain);
|
|
950
976
|
for (const turn of turns) {
|
|
@@ -966,7 +992,7 @@ async function consolidateDay(date, options) {
|
|
|
966
992
|
fs2.mkdirSync(dir, { recursive: true });
|
|
967
993
|
fs2.writeFileSync(dayPath, markdown, "utf-8");
|
|
968
994
|
try {
|
|
969
|
-
const { indexConsolidationSummary } = await import("./consolidation-indexer-
|
|
995
|
+
const { indexConsolidationSummary } = await import("./consolidation-indexer-VIWOP6VO.js");
|
|
970
996
|
await indexConsolidationSummary("daily", date, markdown);
|
|
971
997
|
} catch {
|
|
972
998
|
}
|
|
@@ -987,8 +1013,10 @@ async function extractFactsWithEngine(sessions) {
|
|
|
987
1013
|
const extractor = new FactExtractor({ useVectors: true });
|
|
988
1014
|
for (const { turns } of sessions) {
|
|
989
1015
|
for (const turn of turns) {
|
|
990
|
-
if (turn.role !== "user")
|
|
991
|
-
|
|
1016
|
+
if (turn.role !== "user")
|
|
1017
|
+
continue;
|
|
1018
|
+
if (turn.content.length < 5 || turn.content.length > 5e3)
|
|
1019
|
+
continue;
|
|
992
1020
|
const extracted = await extractor.extract(turn.content);
|
|
993
1021
|
for (const fact of extracted) {
|
|
994
1022
|
const key = fact.fact.toLowerCase().slice(0, 50);
|
|
@@ -1016,7 +1044,8 @@ function extractFactsFallback(sessions) {
|
|
|
1016
1044
|
];
|
|
1017
1045
|
for (const { turns } of sessions) {
|
|
1018
1046
|
for (const turn of turns) {
|
|
1019
|
-
if (turn.role !== "user")
|
|
1047
|
+
if (turn.role !== "user")
|
|
1048
|
+
continue;
|
|
1020
1049
|
for (const pattern of factPatterns) {
|
|
1021
1050
|
const match = turn.content.match(pattern);
|
|
1022
1051
|
if (match) {
|
|
@@ -1045,4 +1074,4 @@ export {
|
|
|
1045
1074
|
getDayFilePath,
|
|
1046
1075
|
consolidateDay
|
|
1047
1076
|
};
|
|
1048
|
-
//# sourceMappingURL=chunk-
|
|
1077
|
+
//# sourceMappingURL=chunk-F6RNEGFX.js.map
|
|
@@ -5803,14 +5803,14 @@ var TwitterAdapter = class {
|
|
|
5803
5803
|
};
|
|
5804
5804
|
|
|
5805
5805
|
export {
|
|
5806
|
+
require_lib,
|
|
5806
5807
|
TelegramAdapter,
|
|
5807
5808
|
WhatsAppAdapter,
|
|
5808
5809
|
IMessageAdapter,
|
|
5809
5810
|
TwitterAdapter,
|
|
5810
5811
|
generateMantra,
|
|
5811
5812
|
validateMantra,
|
|
5812
|
-
require_lib,
|
|
5813
5813
|
renderPairDisplay,
|
|
5814
5814
|
renderPairStatus
|
|
5815
5815
|
};
|
|
5816
|
-
//# sourceMappingURL=chunk-
|
|
5816
|
+
//# sourceMappingURL=chunk-G2QREGXK.js.map
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
blobToVector,
|
|
3
3
|
vectorToBlob
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-D46QTN3G.js";
|
|
5
5
|
import {
|
|
6
6
|
EmbeddingService,
|
|
7
7
|
cosineSimilarity,
|
|
8
8
|
fallbackEmbedding
|
|
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
|
|
|
17
|
-
// ../chitragupta/packages/smriti/
|
|
17
|
+
// ../chitragupta/packages/smriti/dist/consolidation-indexer.js
|
|
18
18
|
var _embeddingService = null;
|
|
19
19
|
function getEmbeddingService() {
|
|
20
20
|
if (!_embeddingService) {
|
|
@@ -76,16 +76,21 @@ function extractSummaryText(markdown, level) {
|
|
|
76
76
|
} else if (trimmed.startsWith("- **Sessions**:") || trimmed.startsWith("- **Turns**:") || trimmed.startsWith("- **Estimated Cost**:")) {
|
|
77
77
|
parts.push(trimmed.replace(/^-\s*/, "").replace(/\*\*/g, ""));
|
|
78
78
|
}
|
|
79
|
-
if (trimmed === "## Recommendations")
|
|
80
|
-
|
|
79
|
+
if (trimmed === "## Recommendations")
|
|
80
|
+
inRecommendations = true;
|
|
81
|
+
else if (trimmed.startsWith("## ") && inRecommendations)
|
|
82
|
+
inRecommendations = false;
|
|
81
83
|
if (inRecommendations && trimmed.startsWith("- ")) {
|
|
82
84
|
parts.push(trimmed.replace(/^-\s*/, ""));
|
|
83
85
|
}
|
|
84
|
-
if (trimmed === "## Vasanas Crystallized")
|
|
85
|
-
|
|
86
|
+
if (trimmed === "## Vasanas Crystallized")
|
|
87
|
+
inVasanas = true;
|
|
88
|
+
else if (trimmed.startsWith("## ") && trimmed !== "## Vasanas Crystallized")
|
|
89
|
+
inVasanas = false;
|
|
86
90
|
if (inVasanas && trimmed.startsWith("|") && !trimmed.startsWith("|--") && !trimmed.startsWith("| Tendency")) {
|
|
87
91
|
const cells = trimmed.split("|").filter(Boolean).map((c) => c.trim());
|
|
88
|
-
if (cells[0])
|
|
92
|
+
if (cells[0])
|
|
93
|
+
parts.push(`Vasana: ${cells[0]}`);
|
|
89
94
|
}
|
|
90
95
|
}
|
|
91
96
|
} else {
|
|
@@ -97,8 +102,10 @@ function extractSummaryText(markdown, level) {
|
|
|
97
102
|
} else if (trimmed.startsWith("- **Sessions**:") || trimmed.startsWith("- **Vasanas Crystallized**:")) {
|
|
98
103
|
parts.push(trimmed.replace(/^-\s*/, "").replace(/\*\*/g, ""));
|
|
99
104
|
}
|
|
100
|
-
if (trimmed === "## Trends")
|
|
101
|
-
|
|
105
|
+
if (trimmed === "## Trends")
|
|
106
|
+
inTrends = true;
|
|
107
|
+
else if (trimmed.startsWith("## ") && trimmed !== "## Trends")
|
|
108
|
+
inTrends = false;
|
|
102
109
|
if (inTrends && trimmed.startsWith("- ")) {
|
|
103
110
|
parts.push(trimmed.replace(/^-\s*/, ""));
|
|
104
111
|
}
|
|
@@ -108,7 +115,8 @@ function extractSummaryText(markdown, level) {
|
|
|
108
115
|
}
|
|
109
116
|
async function indexConsolidationSummary(level, period, markdown, project) {
|
|
110
117
|
const summaryText = extractSummaryText(markdown, level);
|
|
111
|
-
if (!summaryText || summaryText.length < 10)
|
|
118
|
+
if (!summaryText || summaryText.length < 10)
|
|
119
|
+
return;
|
|
112
120
|
let embedding;
|
|
113
121
|
try {
|
|
114
122
|
const svc = getEmbeddingService();
|
|
@@ -124,16 +132,7 @@ async function indexConsolidationSummary(level, period, markdown, project) {
|
|
|
124
132
|
db.prepare(`
|
|
125
133
|
INSERT OR REPLACE INTO embeddings (id, vector, text, source_type, source_id, dimensions, metadata, created_at)
|
|
126
134
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
127
|
-
`).run(
|
|
128
|
-
id,
|
|
129
|
-
vectorToBlob(embedding),
|
|
130
|
-
summaryText.slice(0, 5e3),
|
|
131
|
-
sourceType,
|
|
132
|
-
sourceId,
|
|
133
|
-
embedding.length,
|
|
134
|
-
JSON.stringify({ level, period, project: project ?? null }),
|
|
135
|
-
Date.now()
|
|
136
|
-
);
|
|
135
|
+
`).run(id, vectorToBlob(embedding), summaryText.slice(0, 5e3), sourceType, sourceId, embedding.length, JSON.stringify({ level, period, project: project ?? null }), Date.now());
|
|
137
136
|
} catch {
|
|
138
137
|
}
|
|
139
138
|
}
|
|
@@ -149,10 +148,8 @@ async function searchConsolidationSummaries(query, level, options) {
|
|
|
149
148
|
const sourceType = `${level}_summary`;
|
|
150
149
|
try {
|
|
151
150
|
const db = getVectorsDb();
|
|
152
|
-
const rows = db.prepare(
|
|
153
|
-
|
|
154
|
-
FROM embeddings WHERE source_type = ?`
|
|
155
|
-
).all(sourceType);
|
|
151
|
+
const rows = db.prepare(`SELECT id, vector, text, source_type, source_id, metadata
|
|
152
|
+
FROM embeddings WHERE source_type = ?`).all(sourceType);
|
|
156
153
|
const scored = [];
|
|
157
154
|
for (const row of rows) {
|
|
158
155
|
let meta = {};
|
|
@@ -160,7 +157,8 @@ async function searchConsolidationSummaries(query, level, options) {
|
|
|
160
157
|
meta = JSON.parse(row.metadata ?? "{}");
|
|
161
158
|
} catch {
|
|
162
159
|
}
|
|
163
|
-
if (options?.project && meta.project && meta.project !== options.project)
|
|
160
|
+
if (options?.project && meta.project && meta.project !== options.project)
|
|
161
|
+
continue;
|
|
164
162
|
const vector = blobToVector(row.vector);
|
|
165
163
|
const score = cosineSimilarity(queryEmbedding, vector);
|
|
166
164
|
if (score > 0.1) {
|
|
@@ -182,15 +180,14 @@ async function backfillConsolidationIndices() {
|
|
|
182
180
|
const counts = { daily: 0, monthly: 0, yearly: 0 };
|
|
183
181
|
try {
|
|
184
182
|
const db = getVectorsDb();
|
|
185
|
-
const existing = new Set(
|
|
186
|
-
db.prepare("SELECT id FROM embeddings WHERE source_type IN ('daily_summary', 'monthly_summary', 'yearly_summary')").all().map((r) => r.id)
|
|
187
|
-
);
|
|
183
|
+
const existing = new Set(db.prepare("SELECT id FROM embeddings WHERE source_type IN ('daily_summary', 'monthly_summary', 'yearly_summary')").all().map((r) => r.id));
|
|
188
184
|
try {
|
|
189
|
-
const { listDayFiles, readDayFile } = await import("./day-consolidation-
|
|
185
|
+
const { listDayFiles, readDayFile } = await import("./day-consolidation-HMHSXIOM.js");
|
|
190
186
|
const dayFiles = listDayFiles();
|
|
191
187
|
for (const date of dayFiles) {
|
|
192
188
|
const id = buildEmbeddingId("daily", date);
|
|
193
|
-
if (existing.has(id))
|
|
189
|
+
if (existing.has(id))
|
|
190
|
+
continue;
|
|
194
191
|
const content = readDayFile(date);
|
|
195
192
|
if (content && content.length > 20) {
|
|
196
193
|
await indexConsolidationSummary("daily", date, content);
|
|
@@ -200,8 +197,8 @@ async function backfillConsolidationIndices() {
|
|
|
200
197
|
} catch {
|
|
201
198
|
}
|
|
202
199
|
try {
|
|
203
|
-
const { PeriodicConsolidation } = await import("./periodic-consolidation-
|
|
204
|
-
const { listSessionProjects } = await import("./session-store-
|
|
200
|
+
const { PeriodicConsolidation } = await import("./periodic-consolidation-D6SSKZ7H.js");
|
|
201
|
+
const { listSessionProjects } = await import("./session-store-O3TS7DUY.js");
|
|
205
202
|
const projectEntries = listSessionProjects();
|
|
206
203
|
for (const entry of projectEntries) {
|
|
207
204
|
const project = entry.project;
|
|
@@ -210,14 +207,17 @@ async function backfillConsolidationIndices() {
|
|
|
210
207
|
for (const report of reports) {
|
|
211
208
|
const level = report.type === "monthly" ? "monthly" : "yearly";
|
|
212
209
|
const id = buildEmbeddingId(level, report.period, project);
|
|
213
|
-
if (existing.has(id))
|
|
210
|
+
if (existing.has(id))
|
|
211
|
+
continue;
|
|
214
212
|
try {
|
|
215
213
|
const fs = await import("node:fs");
|
|
216
214
|
const content = fs.readFileSync(report.path, "utf-8");
|
|
217
215
|
if (content && content.length > 20) {
|
|
218
216
|
await indexConsolidationSummary(level, report.period, content, project);
|
|
219
|
-
if (level === "monthly")
|
|
220
|
-
|
|
217
|
+
if (level === "monthly")
|
|
218
|
+
counts.monthly++;
|
|
219
|
+
else
|
|
220
|
+
counts.yearly++;
|
|
221
221
|
}
|
|
222
222
|
} catch {
|
|
223
223
|
}
|
|
@@ -237,4 +237,4 @@ export {
|
|
|
237
237
|
searchConsolidationSummaries,
|
|
238
238
|
backfillConsolidationIndices
|
|
239
239
|
};
|
|
240
|
-
//# sourceMappingURL=chunk-
|
|
240
|
+
//# sourceMappingURL=chunk-JZTFJE7M.js.map
|