@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.
Files changed (41) hide show
  1. package/chunks/{agentic-tool-loop-2FZK72JO.js → agentic-tool-loop-O3NUV7KG.js} +1 -1
  2. package/chunks/{chunk-UZ6OIVEC.js → chunk-2OBLQJYJ.js} +1 -1
  3. package/chunks/{chunk-O4KV7TFP.js → chunk-3AYSJ7WB.js} +30 -18
  4. package/chunks/{chunk-U62ABYKD.js → chunk-67DXWEKG.js} +3 -3
  5. package/chunks/{chunk-6556EKOB.js → chunk-7AYYXHYZ.js} +25 -24
  6. package/chunks/{chunk-JGI4SDWS.js → chunk-7XV5ISV7.js} +7 -5
  7. package/chunks/{chunk-JAWZ7ANC.js → chunk-A3HOZBC5.js} +11 -7
  8. package/chunks/{chunk-VJHNE47S.js → chunk-D46QTN3G.js} +63 -82
  9. package/chunks/{chunk-PRXQW76U.js → chunk-EG37M4QL.js} +17 -6
  10. package/chunks/{chunk-77725AR7.js → chunk-F6RNEGFX.js} +82 -53
  11. package/chunks/{chunk-MJ74G5RB.js → chunk-G2QREGXK.js} +2 -2
  12. package/chunks/{chunk-AS3DJFY3.js → chunk-JZTFJE7M.js} +39 -39
  13. package/chunks/{chunk-OT4G2L46.js → chunk-LJUEMPLG.js} +202 -154
  14. package/chunks/{chunk-C76USAC5.js → chunk-QFGAB4XD.js} +13 -5
  15. package/chunks/{chunk-M7THR63C.js → chunk-QV4GPIPT.js} +74 -65
  16. package/chunks/{chunk-YJRXLRTE.js → chunk-V2ZIKDN4.js} +9 -8
  17. package/chunks/{chunk-AGK3A7R7.js → chunk-VCUJES75.js} +791 -677
  18. package/chunks/{chunk-N22M7D4P.js → chunk-W4PVGBUH.js} +86 -97
  19. package/chunks/{chunk-TND3MU4Z.js → chunk-Z576WVLG.js} +74 -66
  20. package/chunks/{chunk-HIYHTWFW.js → chunk-ZYY6N3SP.js} +90 -118
  21. package/chunks/{consolidation-indexer-VKQ6DNU3.js → consolidation-indexer-VIWOP6VO.js} +8 -8
  22. package/chunks/{day-consolidation-BH3QU2SZ.js → day-consolidation-HMHSXIOM.js} +4 -4
  23. package/chunks/{src-Y3TGMINC.js → dist-CY5NX2IK.js} +17 -17
  24. package/chunks/graphrag-T2QWNX57.js +14 -0
  25. package/chunks/{hierarchical-temporal-search-PVHVA3NZ.js → hierarchical-temporal-search-U6DG74IR.js} +2 -2
  26. package/chunks/hybrid-search-BYTXCOXP.js +20 -0
  27. package/chunks/{memory-store-A6WOWLWC.js → memory-store-LEERUQGL.js} +3 -3
  28. package/chunks/periodic-consolidation-D6SSKZ7H.js +11 -0
  29. package/chunks/{postgres-WLH3D5HG.js → postgres-7GZDDX77.js} +2 -2
  30. package/chunks/{recall-ZNL4DJ2L.js → recall-LNRQVATQ.js} +7 -7
  31. package/chunks/search-BIODUW2P.js +19 -0
  32. package/chunks/{session-store-3BRPGC6P.js → session-store-O3TS7DUY.js} +5 -5
  33. package/chunks/{sqlite-DHUQGPR5.js → sqlite-7BC4DJTN.js} +2 -2
  34. package/chunks/{vasana-engine-MU25OQ23.js → vasana-engine-BJFHJVGM.js} +4 -4
  35. package/gateway.js +31592 -24973
  36. package/package.json +1 -1
  37. package/pair-cli.js +1 -1
  38. package/chunks/graphrag-D7OXWAWD.js +0 -14
  39. package/chunks/hybrid-search-G2NAJKJ7.js +0 -20
  40. package/chunks/periodic-consolidation-LMYMNS4Q.js +0 -11
  41. package/chunks/search-35JMSGUT.js +0 -19
@@ -144,4 +144,4 @@ async function runAgenticToolLoop(params) {
144
144
  export {
145
145
  runAgenticToolLoop
146
146
  };
147
- //# sourceMappingURL=agentic-tool-loop-2FZK72JO.js.map
147
+ //# sourceMappingURL=agentic-tool-loop-O3NUV7KG.js.map
@@ -195,4 +195,4 @@ export {
195
195
  MemoryError,
196
196
  getChitraguptaHome
197
197
  };
198
- //# sourceMappingURL=chunk-UZ6OIVEC.js.map
198
+ //# sourceMappingURL=chunk-2OBLQJYJ.js.map
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  getMemory,
3
3
  listMemoryScopes
4
- } from "./chunk-6556EKOB.js";
4
+ } from "./chunk-7AYYXHYZ.js";
5
5
  import {
6
6
  listSessions,
7
7
  loadSession
8
- } from "./chunk-HIYHTWFW.js";
8
+ } from "./chunk-ZYY6N3SP.js";
9
9
  import {
10
10
  initAgentSchema
11
- } from "./chunk-YJRXLRTE.js";
11
+ } from "./chunk-V2ZIKDN4.js";
12
12
  import {
13
13
  DatabaseManager
14
- } from "./chunk-U62ABYKD.js";
14
+ } from "./chunk-67DXWEKG.js";
15
15
 
16
- // ../chitragupta/packages/smriti/src/search.ts
16
+ // ../chitragupta/packages/smriti/dist/search.js
17
17
  var _dbInitialized = false;
18
18
  function getAgentDb() {
19
19
  const dbm = DatabaseManager.instance();
@@ -34,16 +34,20 @@ function _resetSearchDbInit() {
34
34
  }
35
35
  function sanitizeFts5Query(query) {
36
36
  const cleaned = query.replace(/[*^"(){}:]/g, "").replace(/\b(NOT|AND|OR|NEAR)\b/gi, "").trim();
37
- if (!cleaned) return "";
37
+ if (!cleaned)
38
+ return "";
38
39
  const terms = cleaned.split(/\s+/).filter((t) => t.length >= 2).map((t) => `"${t}"`).join(" ");
39
40
  return terms;
40
41
  }
41
42
  function recencyBoost(epochMs) {
42
43
  const ageMs = Date.now() - epochMs;
43
44
  const ageHours = ageMs / (1e3 * 60 * 60);
44
- if (ageHours < 1) return 1.5 - 0.2 * (ageHours / 1);
45
- if (ageHours < 24) return 1.3 - 0.2 * ((ageHours - 1) / 23);
46
- if (ageHours < 168) return 1.1 - 0.1 * ((ageHours - 24) / 144);
45
+ if (ageHours < 1)
46
+ return 1.5 - 0.2 * (ageHours / 1);
47
+ if (ageHours < 24)
48
+ return 1.3 - 0.2 * ((ageHours - 1) / 23);
49
+ if (ageHours < 168)
50
+ return 1.1 - 0.1 * ((ageHours - 24) / 144);
47
51
  return 1;
48
52
  }
49
53
  function recencyBoostIso(isoDate) {
@@ -201,7 +205,8 @@ var BM25Corpus = class {
201
205
  let score = 0;
202
206
  for (const term of queryTerms) {
203
207
  const tf = doc.tf.get(term) ?? 0;
204
- if (tf === 0) continue;
208
+ if (tf === 0)
209
+ continue;
205
210
  const idf = this.idf(term);
206
211
  const numerator = tf * (BM25_K1 + 1);
207
212
  const denominator = tf + BM25_K1 * (1 - BM25_B + BM25_B * (doc.length / (this.avgDl || 1)));
@@ -211,18 +216,21 @@ var BM25Corpus = class {
211
216
  }
212
217
  query(queryText) {
213
218
  const queryTerms = tokenize(queryText);
214
- if (queryTerms.length === 0) return [];
219
+ if (queryTerms.length === 0)
220
+ return [];
215
221
  const results = [];
216
222
  for (const doc of this.documents) {
217
223
  const score = this.scoreDocument(doc, queryTerms);
218
- if (score > 0) results.push({ payload: doc.payload, score });
224
+ if (score > 0)
225
+ results.push({ payload: doc.payload, score });
219
226
  }
220
227
  results.sort((a, b) => b.score - a.score);
221
228
  return results;
222
229
  }
223
230
  };
224
231
  function searchSessions(query, project) {
225
- if (!query || query.trim().length === 0) return [];
232
+ if (!query || query.trim().length === 0)
233
+ return [];
226
234
  try {
227
235
  return searchSessionsFts5(query, project);
228
236
  } catch (err) {
@@ -233,7 +241,8 @@ function searchSessions(query, project) {
233
241
  }
234
242
  function searchSessionsFts5(query, project) {
235
243
  const ftsQuery = sanitizeFts5Query(query);
236
- if (!ftsQuery) return [];
244
+ if (!ftsQuery)
245
+ return [];
237
246
  const db = getAgentDb();
238
247
  const sql = project ? `SELECT t.session_id, t.turn_number, t.content, f.rank,
239
248
  s.title, s.project, s.created_at, s.updated_at,
@@ -318,20 +327,23 @@ function searchSessionsBm25(query, project) {
318
327
  return boosted.map((s) => s.meta);
319
328
  }
320
329
  function searchMemory(query) {
321
- if (!query || query.trim().length === 0) return [];
330
+ if (!query || query.trim().length === 0)
331
+ return [];
322
332
  const scopes = listMemoryScopes();
323
333
  const corpus = new BM25Corpus();
324
334
  for (const scope of scopes) {
325
335
  try {
326
336
  const content = getMemory(scope);
327
- if (!content) continue;
337
+ if (!content)
338
+ continue;
328
339
  corpus.addDocument({ scope, content }, content);
329
340
  } catch {
330
341
  }
331
342
  }
332
343
  corpus.finalize();
333
344
  const results = corpus.query(query);
334
- if (results.length === 0) return [];
345
+ if (results.length === 0)
346
+ return [];
335
347
  const maxScore = results[0].score;
336
348
  return results.map((r) => ({
337
349
  scope: r.payload.scope,
@@ -346,4 +358,4 @@ export {
346
358
  searchSessions,
347
359
  searchMemory
348
360
  };
349
- //# sourceMappingURL=chunk-O4KV7TFP.js.map
361
+ //# sourceMappingURL=chunk-3AYSJ7WB.js.map
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  getChitraguptaHome
3
- } from "./chunk-UZ6OIVEC.js";
3
+ } from "./chunk-2OBLQJYJ.js";
4
4
 
5
- // ../chitragupta/packages/smriti/src/db/database.ts
5
+ // ../chitragupta/packages/smriti/dist/db/database.js
6
6
  import Database from "better-sqlite3";
7
7
  import fs from "fs";
8
8
  import path from "path";
@@ -120,4 +120,4 @@ var DatabaseManager = class _DatabaseManager {
120
120
  export {
121
121
  DatabaseManager
122
122
  };
123
- //# sourceMappingURL=chunk-U62ABYKD.js.map
123
+ //# sourceMappingURL=chunk-67DXWEKG.js.map
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  MemoryError,
3
3
  getChitraguptaHome
4
- } from "./chunk-UZ6OIVEC.js";
4
+ } from "./chunk-2OBLQJYJ.js";
5
5
 
6
- // ../chitragupta/packages/smriti/src/memory-store.ts
6
+ // ../chitragupta/packages/smriti/dist/memory-store.js
7
7
  import fs from "fs";
8
8
  import path from "path";
9
9
  import crypto from "crypto";
@@ -46,28 +46,27 @@ function scopeKey(scope) {
46
46
  }
47
47
  function getMemory(scope) {
48
48
  if (scope.type === "session") {
49
- throw new MemoryError(
50
- "Session memory is stored within the session file. Use loadSession() to access it."
51
- );
49
+ throw new MemoryError("Session memory is stored within the session file. Use loadSession() to access it.");
52
50
  }
53
51
  const filePath = resolveMemoryPath(scope);
54
- if (!filePath) return "";
52
+ if (!filePath)
53
+ return "";
55
54
  try {
56
55
  return fs.readFileSync(filePath, "utf-8");
57
56
  } catch (err) {
58
57
  const isNotFound = err.code === "ENOENT" || err instanceof Error && err.message.includes("ENOENT");
59
- if (isNotFound) return "";
58
+ if (isNotFound)
59
+ return "";
60
60
  throw new MemoryError(`Failed to read memory at ${filePath}: ${err}`);
61
61
  }
62
62
  }
63
63
  function updateMemory(scope, content) {
64
64
  if (scope.type === "session") {
65
- throw new MemoryError(
66
- "Session memory is stored within the session file. Use saveSession() to update it."
67
- );
65
+ throw new MemoryError("Session memory is stored within the session file. Use saveSession() to update it.");
68
66
  }
69
67
  const filePath = resolveMemoryPath(scope);
70
- if (!filePath) return Promise.resolve();
68
+ if (!filePath)
69
+ return Promise.resolve();
71
70
  const key = scopeKey(scope);
72
71
  const prev = memoryWriteQueues.get(key) ?? Promise.resolve();
73
72
  const next = prev.then(() => {
@@ -87,12 +86,11 @@ function updateMemory(scope, content) {
87
86
  }
88
87
  function appendMemory(scope, entry) {
89
88
  if (scope.type === "session") {
90
- throw new MemoryError(
91
- "Session memory is stored within the session file. Use addTurn() to append."
92
- );
89
+ throw new MemoryError("Session memory is stored within the session file. Use addTurn() to append.");
93
90
  }
94
91
  const filePath = resolveMemoryPath(scope);
95
- if (!filePath) return Promise.resolve();
92
+ if (!filePath)
93
+ return Promise.resolve();
96
94
  const key = scopeKey(scope);
97
95
  const prev = memoryWriteQueues.get(key) ?? Promise.resolve();
98
96
  const next = prev.then(() => {
@@ -111,7 +109,8 @@ ${entry}
111
109
  existing = fs.readFileSync(filePath, "utf-8");
112
110
  } catch (readErr) {
113
111
  const isNotFound = readErr.code === "ENOENT" || readErr instanceof Error && readErr.message.includes("ENOENT");
114
- if (!isNotFound) throw readErr;
112
+ if (!isNotFound)
113
+ throw readErr;
115
114
  }
116
115
  if (existing !== null) {
117
116
  const totalSize = Buffer.byteLength(existing, "utf-8") + Buffer.byteLength(formatted, "utf-8");
@@ -126,7 +125,8 @@ ${entry}
126
125
  fs.writeFileSync(filePath, header + formatted, "utf-8");
127
126
  }
128
127
  } catch (err) {
129
- if (err instanceof MemoryError) throw err;
128
+ if (err instanceof MemoryError)
129
+ throw err;
130
130
  throw new MemoryError(`Failed to append memory at ${filePath}: ${err}`);
131
131
  }
132
132
  }).finally(() => {
@@ -146,7 +146,8 @@ function truncateToFit(existing, incoming) {
146
146
  let size = Buffer.byteLength(header, "utf-8");
147
147
  for (let i = segments.length - 1; i >= 1; i--) {
148
148
  const segSize = Buffer.byteLength(ENTRY_SEPARATOR + segments[i], "utf-8");
149
- if (size + segSize > budget) break;
149
+ if (size + segSize > budget)
150
+ break;
150
151
  size += segSize;
151
152
  kept.unshift(segments[i]);
152
153
  }
@@ -155,18 +156,18 @@ function truncateToFit(existing, incoming) {
155
156
  }
156
157
  function deleteMemory(scope) {
157
158
  if (scope.type === "session") {
158
- throw new MemoryError(
159
- "Session memory is stored within the session file. Use deleteSession() to remove."
160
- );
159
+ throw new MemoryError("Session memory is stored within the session file. Use deleteSession() to remove.");
161
160
  }
162
161
  const filePath = resolveMemoryPath(scope);
163
- if (!filePath) return;
162
+ if (!filePath)
163
+ return;
164
164
  try {
165
165
  try {
166
166
  fs.unlinkSync(filePath);
167
167
  } catch (unlinkErr) {
168
168
  const isNotFound = unlinkErr.code === "ENOENT" || unlinkErr instanceof Error && unlinkErr.message.includes("ENOENT");
169
- if (!isNotFound) throw unlinkErr;
169
+ if (!isNotFound)
170
+ throw unlinkErr;
170
171
  }
171
172
  const dir = path.dirname(filePath);
172
173
  try {
@@ -243,4 +244,4 @@ export {
243
244
  deleteMemory,
244
245
  listMemoryScopes
245
246
  };
246
- //# sourceMappingURL=chunk-6556EKOB.js.map
247
+ //# sourceMappingURL=chunk-7AYYXHYZ.js.map
@@ -1,4 +1,4 @@
1
- // ../chitragupta/packages/smriti/src/hierarchical-temporal-search.ts
1
+ // ../chitragupta/packages/smriti/dist/hierarchical-temporal-search.js
2
2
  var DEPTH_BOOST = {
3
3
  yearly: 0.6,
4
4
  monthly: 0.8,
@@ -7,7 +7,7 @@ var DEPTH_BOOST = {
7
7
  async function hierarchicalTemporalSearch(query, options) {
8
8
  const limit = options?.limit ?? 10;
9
9
  const results = [];
10
- const { searchConsolidationSummaries } = await import("./consolidation-indexer-VKQ6DNU3.js");
10
+ const { searchConsolidationSummaries } = await import("./consolidation-indexer-VIWOP6VO.js");
11
11
  const yearlyHits = await searchConsolidationSummaries(query, "yearly", {
12
12
  limit: 3,
13
13
  project: options?.project
@@ -22,7 +22,8 @@ async function hierarchicalTemporalSearch(query, options) {
22
22
  limit,
23
23
  project: options?.project
24
24
  });
25
- if (dailyHits.length === 0) return [];
25
+ if (dailyHits.length === 0)
26
+ return [];
26
27
  for (const hit of dailyHits) {
27
28
  results.push({
28
29
  score: hit.score * DEPTH_BOOST.daily,
@@ -110,7 +111,8 @@ function deduplicateAndSort(results, limit) {
110
111
  results.sort((a, b) => b.score - a.score);
111
112
  for (const r of results) {
112
113
  const key = `${r.level}:${r.period}`;
113
- if (seen.has(key)) continue;
114
+ if (seen.has(key))
115
+ continue;
114
116
  seen.add(key);
115
117
  unique.push(r);
116
118
  }
@@ -120,4 +122,4 @@ function deduplicateAndSort(results, limit) {
120
122
  export {
121
123
  hierarchicalTemporalSearch
122
124
  };
123
- //# sourceMappingURL=chunk-JGI4SDWS.js.map
125
+ //# sourceMappingURL=chunk-7XV5ISV7.js.map
@@ -1,4 +1,4 @@
1
- // ../chitragupta/packages/smriti/src/graphrag-scoring.ts
1
+ // ../chitragupta/packages/smriti/dist/graphrag-scoring.js
2
2
  var ALPHA = 0.6;
3
3
  var BETA = 0.25;
4
4
  var GAMMA = 0.15;
@@ -39,7 +39,8 @@ var STOP_WORDS = /* @__PURE__ */ new Set([
39
39
  "no"
40
40
  ]);
41
41
  function cosineSimilarity(a, b) {
42
- if (a.length !== b.length) return 0;
42
+ if (a.length !== b.length)
43
+ return 0;
43
44
  let dotProduct = 0;
44
45
  let normA = 0;
45
46
  let normB = 0;
@@ -49,7 +50,8 @@ function cosineSimilarity(a, b) {
49
50
  normB += b[i] * b[i];
50
51
  }
51
52
  const denominator = Math.sqrt(normA) * Math.sqrt(normB);
52
- if (denominator === 0) return 0;
53
+ if (denominator === 0)
54
+ return 0;
53
55
  return dotProduct / denominator;
54
56
  }
55
57
  function estimateTokens(text) {
@@ -61,7 +63,8 @@ function tokenize(text) {
61
63
  function textMatchScore(query, docText) {
62
64
  const queryTokens = tokenize(query);
63
65
  const docTokens = tokenize(docText);
64
- if (queryTokens.length === 0 || docTokens.length === 0) return 0;
66
+ if (queryTokens.length === 0 || docTokens.length === 0)
67
+ return 0;
65
68
  const docTf = /* @__PURE__ */ new Map();
66
69
  for (const token of docTokens) {
67
70
  docTf.set(token, (docTf.get(token) ?? 0) + 1);
@@ -81,7 +84,7 @@ function textMatchScore(query, docText) {
81
84
  return Math.min(score, 1);
82
85
  }
83
86
 
84
- // ../chitragupta/packages/smriti/src/embedding-service.ts
87
+ // ../chitragupta/packages/smriti/dist/embedding-service.js
85
88
  var FALLBACK_DIM = 384;
86
89
  var DEFAULT_MAX_CACHE = 5e3;
87
90
  var MAX_CACHE_CEILING = 2e4;
@@ -155,7 +158,8 @@ var EmbeddingService = class {
155
158
  async getEmbedding(text) {
156
159
  const cacheKey = fnv1aHash(text);
157
160
  const cached = this.cache.get(cacheKey);
158
- if (cached) return cached;
161
+ if (cached)
162
+ return cached;
159
163
  let vector;
160
164
  if (this.provider) {
161
165
  if (this.providerAvailable === null) {
@@ -205,4 +209,4 @@ export {
205
209
  fallbackEmbedding,
206
210
  EmbeddingService
207
211
  };
208
- //# sourceMappingURL=chunk-JAWZ7ANC.js.map
212
+ //# sourceMappingURL=chunk-A3HOZBC5.js.map
@@ -1,26 +1,26 @@
1
1
  import {
2
2
  listSessions,
3
3
  loadSession
4
- } from "./chunk-HIYHTWFW.js";
4
+ } from "./chunk-ZYY6N3SP.js";
5
5
  import {
6
6
  EmbeddingService,
7
7
  cosineSimilarity,
8
8
  estimateTokens
9
- } from "./chunk-JAWZ7ANC.js";
9
+ } from "./chunk-A3HOZBC5.js";
10
10
  import {
11
11
  initVectorsSchema
12
- } from "./chunk-YJRXLRTE.js";
12
+ } from "./chunk-V2ZIKDN4.js";
13
13
  import {
14
14
  DatabaseManager
15
- } from "./chunk-U62ABYKD.js";
15
+ } from "./chunk-67DXWEKG.js";
16
16
  import {
17
17
  getChitraguptaHome
18
- } from "./chunk-UZ6OIVEC.js";
18
+ } from "./chunk-2OBLQJYJ.js";
19
19
 
20
- // ../chitragupta/packages/smriti/src/recall.ts
20
+ // ../chitragupta/packages/smriti/dist/recall.js
21
21
  import fs3 from "fs";
22
22
 
23
- // ../chitragupta/packages/smriti/src/streams.ts
23
+ // ../chitragupta/packages/smriti/dist/streams.js
24
24
  import fs from "fs";
25
25
  import path from "path";
26
26
  var STREAM_CONFIGS = {
@@ -50,9 +50,7 @@ var STREAM_CONFIGS = {
50
50
  }
51
51
  };
52
52
  var STREAM_ORDER = ["identity", "projects", "tasks", "flow"];
53
- var PRESERVATION_RATIOS = STREAM_ORDER.map(
54
- (s) => STREAM_CONFIGS[s].preservation
55
- );
53
+ var PRESERVATION_RATIOS = STREAM_ORDER.map((s) => STREAM_CONFIGS[s].preservation);
56
54
  function getStreamsRoot() {
57
55
  return path.join(getChitraguptaHome(), "smriti", "streams");
58
56
  }
@@ -166,7 +164,8 @@ var StreamManager = class {
166
164
  */
167
165
  readContent(streamType, deviceId) {
168
166
  const raw = this.read(streamType, deviceId);
169
- if (!raw) return "";
167
+ if (!raw)
168
+ return "";
170
169
  const { content } = parseStreamFile(raw);
171
170
  return content;
172
171
  }
@@ -240,10 +239,7 @@ ${entry}`;
240
239
  * than ephemeral streams (flow).
241
240
  */
242
241
  getStreamBudgets(totalBudget) {
243
- const totalPreservation = STREAM_ORDER.reduce(
244
- (sum, s) => sum + STREAM_CONFIGS[s].preservation,
245
- 0
246
- );
242
+ const totalPreservation = STREAM_ORDER.reduce((sum, s) => sum + STREAM_CONFIGS[s].preservation, 0);
247
243
  const budgets = {};
248
244
  for (const stream of STREAM_ORDER) {
249
245
  const ratio = STREAM_CONFIGS[stream].preservation / totalPreservation;
@@ -268,9 +264,11 @@ ${entry}`;
268
264
  */
269
265
  enforcePreservation(streamType, maxTokens, deviceId) {
270
266
  const raw = this.read(streamType, deviceId);
271
- if (!raw) return 0;
267
+ if (!raw)
268
+ return 0;
272
269
  const currentTokens = estimateTokens(raw);
273
- if (currentTokens <= maxTokens) return 0;
270
+ if (currentTokens <= maxTokens)
271
+ return 0;
274
272
  const { content } = parseStreamFile(raw);
275
273
  const ENTRY_SEP = /(\n\n\*\d{4}-)/;
276
274
  const parts = content.split(ENTRY_SEP);
@@ -312,7 +310,8 @@ ${entry}`;
312
310
  */
313
311
  listFlowDevices() {
314
312
  const flowDir = path.join(this.root, "flow");
315
- if (!fs.existsSync(flowDir)) return [];
313
+ if (!fs.existsSync(flowDir))
314
+ return [];
316
315
  try {
317
316
  return fs.readdirSync(flowDir).filter((f) => f.endsWith(".md")).map((f) => f.replace(/\.md$/, ""));
318
317
  } catch {
@@ -327,7 +326,7 @@ ${entry}`;
327
326
  }
328
327
  };
329
328
 
330
- // ../chitragupta/packages/smriti/src/recall-scoring.ts
329
+ // ../chitragupta/packages/smriti/dist/recall-scoring.js
331
330
  var _embeddingService = new EmbeddingService();
332
331
  function configureRecallScoring(options) {
333
332
  if (options.embeddingService) {
@@ -343,7 +342,8 @@ function summarizeSession(session) {
343
342
  if (turn.role === "user") {
344
343
  parts.push(turn.content.slice(0, 200));
345
344
  }
346
- if (parts.join(" ").length > 400) break;
345
+ if (parts.join(" ").length > 400)
346
+ break;
347
347
  }
348
348
  return parts.join(" | ").slice(0, 500);
349
349
  }
@@ -367,7 +367,7 @@ function resetOllamaAvailability() {
367
367
  _embeddingService.resetAvailability();
368
368
  }
369
369
 
370
- // ../chitragupta/packages/smriti/src/recall-storage.ts
370
+ // ../chitragupta/packages/smriti/dist/recall-storage.js
371
371
  import fs2 from "fs";
372
372
  import path2 from "path";
373
373
  var DEFAULT_TOP_K = 10;
@@ -383,11 +383,7 @@ function vectorToBlob(vector) {
383
383
  return Buffer.from(float32.buffer);
384
384
  }
385
385
  function blobToVector(blob) {
386
- const float32 = new Float32Array(
387
- blob.buffer,
388
- blob.byteOffset,
389
- blob.byteLength / 4
390
- );
386
+ const float32 = new Float32Array(blob.buffer, blob.byteOffset, blob.byteLength / 4);
391
387
  return Array.from(float32);
392
388
  }
393
389
  function migrateEmbeddingsJson() {
@@ -418,22 +414,13 @@ function migrateEmbeddingsJson() {
418
414
  `);
419
415
  for (const entry of entries) {
420
416
  try {
421
- const result = insert.run(
422
- entry.id,
423
- vectorToBlob(entry.vector),
424
- entry.text,
425
- entry.source,
426
- entry.sourceId,
427
- entry.vector.length,
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
- );
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());
437
424
  if (result.changes > 0) {
438
425
  migrated++;
439
426
  } else {
@@ -455,7 +442,7 @@ function migrateEmbeddingsJson() {
455
442
  return { migrated, skipped };
456
443
  }
457
444
 
458
- // ../chitragupta/packages/smriti/src/recall.ts
445
+ // ../chitragupta/packages/smriti/dist/recall.js
459
446
  var _dbInitialized = false;
460
447
  function _resetRecallDbInit() {
461
448
  _dbInitialized = false;
@@ -520,22 +507,13 @@ var RecallEngine = class {
520
507
  VALUES (?, ?, ?, ?, ?, ?, ?, ?)
521
508
  `);
522
509
  for (const entry of this.entries) {
523
- insert.run(
524
- entry.id,
525
- vectorToBlob(entry.vector),
526
- entry.text,
527
- entry.source,
528
- entry.sourceId,
529
- entry.vector.length,
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
- );
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());
539
517
  }
540
518
  });
541
519
  txn();
@@ -559,21 +537,16 @@ var RecallEngine = class {
559
537
  try {
560
538
  const dir = getIndexDir();
561
539
  fs3.mkdirSync(dir, { recursive: true });
562
- fs3.writeFileSync(
563
- getEmbeddingsPath(),
564
- JSON.stringify(this.entries, null, " "),
565
- "utf-8"
566
- );
540
+ fs3.writeFileSync(getEmbeddingsPath(), JSON.stringify(this.entries, null, " "), "utf-8");
567
541
  } catch {
568
542
  }
569
543
  }
570
544
  // ─── Session Indexing ────────────────────────────────────────────
571
545
  /** Index a session's turns into the embedding store. */
572
546
  async indexSession(session) {
573
- if (!this.loaded) this.loadIndex();
574
- this.entries = this.entries.filter(
575
- (e) => !(e.source === "session" && e.sourceId === session.meta.id)
576
- );
547
+ if (!this.loaded)
548
+ this.loadIndex();
549
+ this.entries = this.entries.filter((e) => !(e.source === "session" && e.sourceId === session.meta.id));
577
550
  const indexText = extractIndexText(session);
578
551
  const summary = summarizeSession(session);
579
552
  const chunkSize = 4e3;
@@ -583,7 +556,8 @@ var RecallEngine = class {
583
556
  } else {
584
557
  for (let i = 0; i < indexText.length; i += chunkSize - 500) {
585
558
  chunks.push(indexText.slice(i, i + chunkSize));
586
- if (i + chunkSize >= indexText.length) break;
559
+ if (i + chunkSize >= indexText.length)
560
+ break;
587
561
  }
588
562
  }
589
563
  for (let i = 0; i < chunks.length; i++) {
@@ -604,12 +578,12 @@ var RecallEngine = class {
604
578
  }
605
579
  /** Index a memory stream into the embedding store. */
606
580
  async indexStream(streamType, content, deviceId) {
607
- if (!this.loaded) this.loadIndex();
581
+ if (!this.loaded)
582
+ this.loadIndex();
608
583
  const sourceId = deviceId ? `stream-${streamType}-${deviceId}` : `stream-${streamType}`;
609
- this.entries = this.entries.filter(
610
- (e) => !(e.source === "stream" && e.sourceId === sourceId)
611
- );
612
- 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;
613
587
  const vector = await getEmbedding(content.slice(0, 8e3));
614
588
  this.entries.push({
615
589
  id: sourceId,
@@ -628,23 +602,28 @@ var RecallEngine = class {
628
602
  // ─── Recall (Search) ─────────────────────────────────────────────
629
603
  /** Search all indexed embeddings for the given query string. */
630
604
  async recall(query, options) {
631
- if (!this.loaded) this.loadIndex();
632
- if (this.entries.length === 0) return [];
605
+ if (!this.loaded)
606
+ this.loadIndex();
607
+ if (this.entries.length === 0)
608
+ return [];
633
609
  const topK = options?.topK ?? DEFAULT_TOP_K;
634
610
  const threshold = options?.threshold ?? DEFAULT_THRESHOLD;
635
611
  const queryVector = await getEmbedding(query);
636
612
  const scored = [];
637
613
  for (const entry of this.entries) {
638
- if (options?.deviceFilter && entry.deviceId !== options.deviceFilter) continue;
614
+ if (options?.deviceFilter && entry.deviceId !== options.deviceFilter)
615
+ continue;
639
616
  if (options?.dateRange) {
640
617
  const entryDate = new Date(entry.date).getTime();
641
618
  const rangeStart = new Date(options.dateRange[0]).getTime();
642
619
  const rangeEnd = new Date(options.dateRange[1]).getTime();
643
- if (entryDate < rangeStart || entryDate > rangeEnd) continue;
620
+ if (entryDate < rangeStart || entryDate > rangeEnd)
621
+ continue;
644
622
  }
645
623
  if (options?.tagFilter && options.tagFilter.length > 0) {
646
624
  const hasTag = options.tagFilter.some((tag) => entry.tags.includes(tag));
647
- if (!hasTag) continue;
625
+ if (!hasTag)
626
+ continue;
648
627
  }
649
628
  const score = cosineSimilarity(queryVector, entry.vector);
650
629
  if (score >= threshold) {
@@ -655,8 +634,10 @@ var RecallEngine = class {
655
634
  const seen = /* @__PURE__ */ new Set();
656
635
  const results = [];
657
636
  for (const { entry, score } of scored) {
658
- if (results.length >= topK) break;
659
- if (seen.has(entry.sourceId)) continue;
637
+ if (results.length >= topK)
638
+ break;
639
+ if (seen.has(entry.sourceId))
640
+ continue;
660
641
  seen.add(entry.sourceId);
661
642
  results.push({
662
643
  sessionId: entry.sourceId,
@@ -722,4 +703,4 @@ export {
722
703
  _resetRecallDbInit,
723
704
  RecallEngine
724
705
  };
725
- //# sourceMappingURL=chunk-VJHNE47S.js.map
706
+ //# sourceMappingURL=chunk-D46QTN3G.js.map