@yugenlab/vaayu 0.1.2 → 0.1.3

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 (32) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/chunks/{chunk-E5A3SCDJ.js → chunk-6556EKOB.js} +2 -2
  4. package/chunks/{chunk-FPNQLJLD.js → chunk-7UOXFHEB.js} +6 -6
  5. package/chunks/{chunk-NBXCXQ3H.js → chunk-D3RVJGO7.js} +2 -2
  6. package/chunks/{chunk-XRHUKKBC.js → chunk-DOQMEQ5S.js} +6 -6
  7. package/chunks/{chunk-OWBBY5XP.js → chunk-IGBRBFXX.js} +2 -2
  8. package/chunks/{chunk-F35MWELH.js → chunk-LVE2EOOH.js} +7 -7
  9. package/chunks/{chunk-2ARPXEDC.js → chunk-NHRBVSN3.js} +3 -3
  10. package/chunks/{chunk-F4T7POKM.js → chunk-OBYBBGHA.js} +2 -2
  11. package/chunks/{chunk-UW6E7IC4.js → chunk-PJEYJQ2C.js} +4 -4
  12. package/chunks/{chunk-SLA2OIMG.js → chunk-S2HDNNC7.js} +3 -3
  13. package/chunks/{chunk-DQMAQ2VL.js → chunk-TEQKXGIK.js} +5 -5
  14. package/chunks/{chunk-UQLPHNGH.js → chunk-U62ABYKD.js} +2 -2
  15. package/chunks/{chunk-KC6NRZ7U.js → chunk-UZ6OIVEC.js} +1 -1
  16. package/chunks/{chunk-5Z2BKSFF.js → chunk-YSC77CKZ.js} +427 -85
  17. package/chunks/{consolidation-indexer-A46RJU4R.js → consolidation-indexer-CD6DS2HO.js} +6 -6
  18. package/chunks/{day-consolidation-GQ2FDCR2.js → day-consolidation-U3X6P4ZG.js} +3 -3
  19. package/chunks/{graphrag-6YZ5YPLK.js → graphrag-LAZSXLLI.js} +4 -4
  20. package/chunks/{hierarchical-temporal-search-VA4D3SON.js → hierarchical-temporal-search-ETXYYJZK.js} +2 -2
  21. package/chunks/{hybrid-search-6XMUT66S.js → hybrid-search-TX6T3KYH.js} +7 -7
  22. package/chunks/{memory-store-KNJPMBLQ.js → memory-store-A6WOWLWC.js} +3 -3
  23. package/chunks/periodic-consolidation-4MACZE6S.js +11 -0
  24. package/chunks/{recall-THTI6ZO2.js → recall-IUPQCBYP.js} +5 -5
  25. package/chunks/{search-V7DJ3VNL.js → search-HHSVHBXC.js} +6 -6
  26. package/chunks/{session-store-GRKGTMHI.js → session-store-NDUDYAC7.js} +4 -4
  27. package/chunks/{src-54LTTDTH.js → src-ZAKUL232.js} +51 -41
  28. package/chunks/vasana-engine-G6BPOFX7.js +10 -0
  29. package/gateway.js +391 -84
  30. package/package.json +1 -1
  31. package/chunks/periodic-consolidation-N5MR77ZN.js +0 -11
  32. package/chunks/vasana-engine-Z4RXW2SB.js +0 -10
@@ -1,26 +1,30 @@
1
+ import {
2
+ getDayFilePath,
3
+ listDayFiles
4
+ } from "./chunk-7UOXFHEB.js";
1
5
  import {
2
6
  PRESERVATION_RATIOS,
3
7
  RecallEngine,
4
8
  STREAM_ORDER,
5
9
  StreamManager
6
- } from "./chunk-F35MWELH.js";
7
- import {
8
- cosineSimilarity,
9
- estimateTokens
10
- } from "./chunk-JAWZ7ANC.js";
10
+ } from "./chunk-LVE2EOOH.js";
11
11
  import {
12
12
  createSession,
13
13
  listSessions,
14
14
  loadSession,
15
15
  saveSession
16
- } from "./chunk-2ARPXEDC.js";
16
+ } from "./chunk-NHRBVSN3.js";
17
+ import {
18
+ cosineSimilarity,
19
+ estimateTokens
20
+ } from "./chunk-JAWZ7ANC.js";
17
21
  import {
18
22
  DatabaseManager
19
- } from "./chunk-UQLPHNGH.js";
23
+ } from "./chunk-U62ABYKD.js";
20
24
  import {
21
25
  SessionError,
22
26
  getChitraguptaHome
23
- } from "./chunk-KC6NRZ7U.js";
27
+ } from "./chunk-UZ6OIVEC.js";
24
28
 
25
29
  // ../chitragupta/packages/smriti/src/session-export.ts
26
30
  function exportSessionToJson(session) {
@@ -224,6 +228,339 @@ function validateExportedSession(data) {
224
228
  }
225
229
  }
226
230
 
231
+ // ../chitragupta/packages/smriti/src/cross-machine-sync.ts
232
+ import fs from "node:fs";
233
+ import os from "node:os";
234
+ import path from "node:path";
235
+ import crypto from "node:crypto";
236
+ var SNAPSHOT_VERSION = 1;
237
+ var ENTRY_SEPARATOR = "\n---\n\n";
238
+ function sha256(content) {
239
+ return crypto.createHash("sha256").update(content, "utf-8").digest("hex");
240
+ }
241
+ function toPortablePath(absPath, home) {
242
+ const rel = path.relative(home, absPath);
243
+ if (!rel || rel.startsWith("..") || path.isAbsolute(rel)) {
244
+ throw new SessionError(`Path escapes Chitragupta home: ${absPath}`);
245
+ }
246
+ return rel.split(path.sep).join("/");
247
+ }
248
+ function resolveSnapshotPath(relPath, home) {
249
+ const normalizedRel = relPath.replaceAll("\\", "/");
250
+ const abs = path.resolve(home, normalizedRel);
251
+ const homeWithSep = home.endsWith(path.sep) ? home : `${home}${path.sep}`;
252
+ if (abs !== home && !abs.startsWith(homeWithSep)) {
253
+ throw new SessionError(`Snapshot path escapes Chitragupta home: ${relPath}`);
254
+ }
255
+ return abs;
256
+ }
257
+ function listMemoryFiles(memoryRoot) {
258
+ if (!fs.existsSync(memoryRoot)) return [];
259
+ const stack = [memoryRoot];
260
+ const files = [];
261
+ while (stack.length > 0) {
262
+ const current = stack.pop();
263
+ let entries = [];
264
+ try {
265
+ entries = fs.readdirSync(current, { withFileTypes: true });
266
+ } catch {
267
+ continue;
268
+ }
269
+ for (const entry of entries) {
270
+ const full = path.join(current, entry.name);
271
+ if (entry.isDirectory()) {
272
+ stack.push(full);
273
+ continue;
274
+ }
275
+ if (entry.isFile() && entry.name.endsWith(".md")) {
276
+ files.push(full);
277
+ }
278
+ }
279
+ }
280
+ return files.sort();
281
+ }
282
+ function readSyncState(home) {
283
+ const statePath = path.join(home, "sync-state.json");
284
+ try {
285
+ if (!fs.existsSync(statePath)) return {};
286
+ const raw = fs.readFileSync(statePath, "utf-8");
287
+ const parsed = JSON.parse(raw);
288
+ return parsed && typeof parsed === "object" ? parsed : {};
289
+ } catch {
290
+ return {};
291
+ }
292
+ }
293
+ function writeSyncState(home, patch) {
294
+ const statePath = path.join(home, "sync-state.json");
295
+ const next = { ...readSyncState(home), ...patch };
296
+ fs.mkdirSync(path.dirname(statePath), { recursive: true });
297
+ fs.writeFileSync(statePath, JSON.stringify(next, null, " "), "utf-8");
298
+ }
299
+ function splitMemory(content) {
300
+ const normalized = content.replaceAll("\r\n", "\n");
301
+ const parts = normalized.split(ENTRY_SEPARATOR);
302
+ if (parts.length <= 1) {
303
+ return { header: normalized.trimEnd(), entries: [] };
304
+ }
305
+ const header = (parts[0] ?? "").trimEnd();
306
+ const entries = parts.slice(1).map((entry) => entry.trim()).filter(Boolean);
307
+ return { header, entries };
308
+ }
309
+ function mergeMemory(localContent, remoteContent) {
310
+ const localTrimmed = localContent.trim();
311
+ const remoteTrimmed = remoteContent.trim();
312
+ if (!localTrimmed) return remoteTrimmed ? `${remoteTrimmed}
313
+ ` : "";
314
+ if (!remoteTrimmed) return localContent.endsWith("\n") ? localContent : `${localContent}
315
+ `;
316
+ if (localContent === remoteContent) return localContent;
317
+ const local = splitMemory(localContent);
318
+ const remote = splitMemory(remoteContent);
319
+ if (local.entries.length === 0 && remote.entries.length === 0) {
320
+ if (localContent.includes(remoteContent)) return localContent;
321
+ if (remoteContent.includes(localContent)) return remoteContent;
322
+ return `${localContent.trimEnd()}
323
+
324
+ ---
325
+
326
+ ${remoteContent.trim()}
327
+ `;
328
+ }
329
+ const header = local.header || remote.header || "# Memory";
330
+ const seen = /* @__PURE__ */ new Set();
331
+ const mergedEntries = [];
332
+ for (const entry of [...local.entries, ...remote.entries]) {
333
+ const key = sha256(entry.replace(/\s+/g, " ").trim().toLowerCase());
334
+ if (seen.has(key)) continue;
335
+ seen.add(key);
336
+ mergedEntries.push(entry.trim());
337
+ }
338
+ let merged = header.trimEnd();
339
+ if (mergedEntries.length > 0) {
340
+ merged += ENTRY_SEPARATOR + mergedEntries.join(ENTRY_SEPARATOR);
341
+ }
342
+ if (!merged.endsWith("\n")) merged += "\n";
343
+ return merged;
344
+ }
345
+ function assertSnapshot(value) {
346
+ if (!value || typeof value !== "object") {
347
+ throw new SessionError("Invalid sync snapshot: expected object");
348
+ }
349
+ const snapshot = value;
350
+ if (snapshot.version !== SNAPSHOT_VERSION) {
351
+ throw new SessionError(`Unsupported sync snapshot version: ${String(snapshot.version)}`);
352
+ }
353
+ if (typeof snapshot.exportedAt !== "string") {
354
+ throw new SessionError("Invalid sync snapshot: missing exportedAt");
355
+ }
356
+ if (!Array.isArray(snapshot.files)) {
357
+ throw new SessionError("Invalid sync snapshot: missing files array");
358
+ }
359
+ for (const file of snapshot.files) {
360
+ if (!file || typeof file !== "object") {
361
+ throw new SessionError("Invalid sync snapshot: file entry must be object");
362
+ }
363
+ const entry = file;
364
+ if (typeof entry.path !== "string" || !entry.path) {
365
+ throw new SessionError("Invalid sync snapshot: file.path must be non-empty string");
366
+ }
367
+ if (entry.kind !== "day" && entry.kind !== "memory") {
368
+ throw new SessionError(`Invalid sync snapshot: unsupported kind for ${String(entry.path)}`);
369
+ }
370
+ if (typeof entry.content !== "string" || typeof entry.sha256 !== "string") {
371
+ throw new SessionError(`Invalid sync snapshot: content/hash missing for ${entry.path}`);
372
+ }
373
+ }
374
+ }
375
+ function createCrossMachineSnapshot(options) {
376
+ const includeDays = options?.includeDays ?? true;
377
+ const includeMemory = options?.includeMemory ?? true;
378
+ if (!includeDays && !includeMemory) {
379
+ throw new SessionError("Snapshot must include at least one category: days or memory");
380
+ }
381
+ const home = getChitraguptaHome();
382
+ const files = [];
383
+ if (includeDays) {
384
+ let dates = listDayFiles();
385
+ if (typeof options?.maxDays === "number" && Number.isFinite(options.maxDays)) {
386
+ dates = dates.slice(0, Math.max(0, Math.floor(options.maxDays)));
387
+ }
388
+ for (const date of dates) {
389
+ const absPath = getDayFilePath(date);
390
+ if (!fs.existsSync(absPath)) continue;
391
+ try {
392
+ const content = fs.readFileSync(absPath, "utf-8");
393
+ const stat = fs.statSync(absPath);
394
+ files.push({
395
+ path: toPortablePath(absPath, home),
396
+ kind: "day",
397
+ content,
398
+ sha256: sha256(content),
399
+ bytes: Buffer.byteLength(content, "utf-8"),
400
+ mtimeMs: stat.mtimeMs
401
+ });
402
+ } catch {
403
+ }
404
+ }
405
+ }
406
+ if (includeMemory) {
407
+ const memoryRoot = path.join(home, "memory");
408
+ for (const absPath of listMemoryFiles(memoryRoot)) {
409
+ try {
410
+ const content = fs.readFileSync(absPath, "utf-8");
411
+ const stat = fs.statSync(absPath);
412
+ files.push({
413
+ path: toPortablePath(absPath, home),
414
+ kind: "memory",
415
+ content,
416
+ sha256: sha256(content),
417
+ bytes: Buffer.byteLength(content, "utf-8"),
418
+ mtimeMs: stat.mtimeMs
419
+ });
420
+ } catch {
421
+ }
422
+ }
423
+ }
424
+ return {
425
+ version: SNAPSHOT_VERSION,
426
+ exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
427
+ source: {
428
+ machine: os.hostname(),
429
+ platform: `${process.platform}-${process.arch}`,
430
+ home
431
+ },
432
+ files
433
+ };
434
+ }
435
+ function writeCrossMachineSnapshot(snapshot, outputPath) {
436
+ assertSnapshot(snapshot);
437
+ const resolved = path.resolve(outputPath);
438
+ fs.mkdirSync(path.dirname(resolved), { recursive: true });
439
+ fs.writeFileSync(resolved, JSON.stringify(snapshot, null, " "), "utf-8");
440
+ writeSyncState(getChitraguptaHome(), {
441
+ lastExportAt: snapshot.exportedAt,
442
+ lastExportPath: resolved
443
+ });
444
+ return resolved;
445
+ }
446
+ function readCrossMachineSnapshot(snapshotPath) {
447
+ const resolved = path.resolve(snapshotPath);
448
+ const raw = fs.readFileSync(resolved, "utf-8");
449
+ const parsed = JSON.parse(raw);
450
+ assertSnapshot(parsed);
451
+ return parsed;
452
+ }
453
+ function getCrossMachineSyncStatus() {
454
+ const home = getChitraguptaHome();
455
+ const state = readSyncState(home);
456
+ const daysCount = listDayFiles().length;
457
+ const memoryCount = listMemoryFiles(path.join(home, "memory")).length;
458
+ return {
459
+ home,
460
+ daysCount,
461
+ memoryCount,
462
+ ...state
463
+ };
464
+ }
465
+ function writeTextFile(filePath, content) {
466
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
467
+ fs.writeFileSync(filePath, content, "utf-8");
468
+ }
469
+ function createConflictPath(conflictRoot, relPath) {
470
+ const ext = path.extname(relPath);
471
+ const base = ext ? relPath.slice(0, -ext.length) : relPath;
472
+ const remoteName = `${base}.remote${ext || ".md"}`;
473
+ return path.join(conflictRoot, remoteName);
474
+ }
475
+ function importCrossMachineSnapshot(source, options) {
476
+ const snapshot = typeof source === "string" ? readCrossMachineSnapshot(source) : source;
477
+ assertSnapshot(snapshot);
478
+ const home = getChitraguptaHome();
479
+ const strategy = options?.strategy ?? "safe";
480
+ const dryRun = options?.dryRun ?? false;
481
+ const importedAt = (/* @__PURE__ */ new Date()).toISOString();
482
+ const conflictRoot = path.join(home, "sync-conflicts", importedAt.replace(/[:.]/g, "-"));
483
+ const totals = {
484
+ files: snapshot.files.length,
485
+ created: 0,
486
+ updated: 0,
487
+ merged: 0,
488
+ skipped: 0,
489
+ conflicts: 0,
490
+ errors: 0
491
+ };
492
+ const changedPaths = [];
493
+ const conflictPaths = [];
494
+ const errorPaths = [];
495
+ for (const file of snapshot.files) {
496
+ try {
497
+ const contentHash = sha256(file.content);
498
+ if (contentHash !== file.sha256) {
499
+ totals.errors += 1;
500
+ errorPaths.push(file.path);
501
+ continue;
502
+ }
503
+ const targetPath = resolveSnapshotPath(file.path, home);
504
+ if (!fs.existsSync(targetPath)) {
505
+ if (!dryRun) writeTextFile(targetPath, file.content);
506
+ totals.created += 1;
507
+ changedPaths.push(file.path);
508
+ continue;
509
+ }
510
+ const localContent = fs.readFileSync(targetPath, "utf-8");
511
+ if (localContent === file.content || sha256(localContent) === file.sha256) {
512
+ totals.skipped += 1;
513
+ continue;
514
+ }
515
+ if (file.kind === "memory") {
516
+ const merged = mergeMemory(localContent, file.content);
517
+ if (merged === localContent) {
518
+ totals.skipped += 1;
519
+ continue;
520
+ }
521
+ if (!dryRun) writeTextFile(targetPath, merged);
522
+ totals.merged += 1;
523
+ changedPaths.push(file.path);
524
+ continue;
525
+ }
526
+ if (strategy === "preferRemote") {
527
+ if (!dryRun) writeTextFile(targetPath, file.content);
528
+ totals.updated += 1;
529
+ changedPaths.push(file.path);
530
+ continue;
531
+ }
532
+ if (strategy === "preferLocal") {
533
+ totals.skipped += 1;
534
+ continue;
535
+ }
536
+ const conflictPath = createConflictPath(conflictRoot, file.path);
537
+ if (!dryRun) writeTextFile(conflictPath, file.content);
538
+ totals.conflicts += 1;
539
+ conflictPaths.push(toPortablePath(conflictPath, home));
540
+ } catch {
541
+ totals.errors += 1;
542
+ errorPaths.push(file.path);
543
+ }
544
+ }
545
+ if (!dryRun) {
546
+ writeSyncState(home, {
547
+ lastImportAt: importedAt,
548
+ lastImportSource: snapshot.source.machine,
549
+ lastImportTotals: totals
550
+ });
551
+ }
552
+ return {
553
+ importedAt,
554
+ sourceExportedAt: snapshot.exportedAt,
555
+ strategy,
556
+ dryRun,
557
+ totals,
558
+ changedPaths,
559
+ conflictPaths,
560
+ errorPaths
561
+ };
562
+ }
563
+
227
564
  // ../chitragupta/packages/smriti/src/branch.ts
228
565
  function branchSession(sessionId, project, branchName, fromTurn) {
229
566
  const original = loadSession(sessionId, project);
@@ -738,13 +1075,13 @@ function writeDeltaMarkdown(delta) {
738
1075
  }
739
1076
 
740
1077
  // ../chitragupta/packages/smriti/src/compactor.ts
741
- import fs from "fs";
742
- import path from "path";
1078
+ import fs2 from "fs";
1079
+ import path2 from "path";
743
1080
  function getCompactionDir() {
744
- return path.join(getChitraguptaHome(), "smriti", "compaction");
1081
+ return path2.join(getChitraguptaHome(), "smriti", "compaction");
745
1082
  }
746
1083
  function getDeltaDir() {
747
- return path.join(getChitraguptaHome(), "smriti", "deltas");
1084
+ return path2.join(getChitraguptaHome(), "smriti", "deltas");
748
1085
  }
749
1086
  function updateIdentityStream(streamManager, signals) {
750
1087
  if (signals.identity.length === 0) return;
@@ -926,17 +1263,17 @@ var SessionCompactor = class {
926
1263
  saveDelta(delta) {
927
1264
  try {
928
1265
  const dir = getDeltaDir();
929
- fs.mkdirSync(dir, { recursive: true });
930
- const filePath = path.join(dir, `${delta.sessionId}.md`);
1266
+ fs2.mkdirSync(dir, { recursive: true });
1267
+ const filePath = path2.join(dir, `${delta.sessionId}.md`);
931
1268
  const markdown = writeDeltaMarkdown(delta);
932
- fs.writeFileSync(filePath, markdown, "utf-8");
1269
+ fs2.writeFileSync(filePath, markdown, "utf-8");
933
1270
  } catch {
934
1271
  }
935
1272
  }
936
1273
  saveMixingMatrix(sessionId, mixingMatrix, signals) {
937
1274
  try {
938
1275
  const dir = getCompactionDir();
939
- fs.mkdirSync(dir, { recursive: true });
1276
+ fs2.mkdirSync(dir, { recursive: true });
940
1277
  const data = {
941
1278
  sessionId,
942
1279
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
@@ -955,8 +1292,8 @@ var SessionCompactor = class {
955
1292
  flow: signals.flow.slice(0, 10)
956
1293
  }
957
1294
  };
958
- const filePath = path.join(dir, `${sessionId}.json`);
959
- fs.writeFileSync(filePath, JSON.stringify(data, null, " "), "utf-8");
1295
+ const filePath = path2.join(dir, `${sessionId}.json`);
1296
+ fs2.writeFileSync(filePath, JSON.stringify(data, null, " "), "utf-8");
960
1297
  } catch {
961
1298
  }
962
1299
  }
@@ -1552,10 +1889,10 @@ function computeSimilarity(a, b) {
1552
1889
  }
1553
1890
 
1554
1891
  // ../chitragupta/packages/smriti/src/checkpoint.ts
1555
- import fs2 from "node:fs";
1556
- import path2 from "node:path";
1892
+ import fs3 from "node:fs";
1893
+ import path3 from "node:path";
1557
1894
  import { randomUUID } from "node:crypto";
1558
- var DEFAULT_CHECKPOINT_DIR = path2.join(".chitragupta", "checkpoints");
1895
+ var DEFAULT_CHECKPOINT_DIR = path3.join(".chitragupta", "checkpoints");
1559
1896
  var DEFAULT_INTERVAL = 3e4;
1560
1897
  var DEFAULT_MAX_CHECKPOINTS = 5;
1561
1898
  var CHECKPOINT_EXT = ".json";
@@ -1585,16 +1922,16 @@ var CheckpointManager = class {
1585
1922
  */
1586
1923
  async save(sessionId, data) {
1587
1924
  const sessionDir = this.sessionDir(sessionId);
1588
- await fs2.promises.mkdir(sessionDir, { recursive: true });
1925
+ await fs3.promises.mkdir(sessionDir, { recursive: true });
1589
1926
  const timestamp = Date.now();
1590
1927
  const uuid = randomUUID().slice(0, 8);
1591
1928
  const filename = `${timestamp}-${uuid}${CHECKPOINT_EXT}`;
1592
- const filePath = path2.join(sessionDir, filename);
1929
+ const filePath = path3.join(sessionDir, filename);
1593
1930
  const tmpPath = filePath + ".tmp";
1594
1931
  const json = JSON.stringify(data, null, 2);
1595
1932
  const sizeBytes = Buffer.byteLength(json, "utf-8");
1596
- await fs2.promises.writeFile(tmpPath, json, "utf-8");
1597
- await fs2.promises.rename(tmpPath, filePath);
1933
+ await fs3.promises.writeFile(tmpPath, json, "utf-8");
1934
+ await fs3.promises.rename(tmpPath, filePath);
1598
1935
  await this.prune(sessionId);
1599
1936
  return {
1600
1937
  id: `${timestamp}-${uuid}`,
@@ -1614,7 +1951,7 @@ var CheckpointManager = class {
1614
1951
  for (const cp of checkpoints) {
1615
1952
  try {
1616
1953
  const filePath = this.checkpointPath(sessionId, cp);
1617
- const raw = await fs2.promises.readFile(filePath, "utf-8");
1954
+ const raw = await fs3.promises.readFile(filePath, "utf-8");
1618
1955
  const data = JSON.parse(raw);
1619
1956
  if (data.version === 1 && data.sessionId === sessionId) {
1620
1957
  return data;
@@ -1631,10 +1968,10 @@ var CheckpointManager = class {
1631
1968
  */
1632
1969
  list(sessionId) {
1633
1970
  const sessionDir = this.sessionDir(sessionId);
1634
- if (!fs2.existsSync(sessionDir)) return [];
1971
+ if (!fs3.existsSync(sessionDir)) return [];
1635
1972
  let entries;
1636
1973
  try {
1637
- entries = fs2.readdirSync(sessionDir);
1974
+ entries = fs3.readdirSync(sessionDir);
1638
1975
  } catch {
1639
1976
  return [];
1640
1977
  }
@@ -1643,22 +1980,22 @@ var CheckpointManager = class {
1643
1980
  if (entry.endsWith(".tmp")) continue;
1644
1981
  const parsed = parseCheckpointFilename(entry);
1645
1982
  if (!parsed) continue;
1646
- const filePath = path2.join(sessionDir, entry);
1983
+ const filePath = path3.join(sessionDir, entry);
1647
1984
  let size = 0;
1648
1985
  let turnCount = 0;
1649
1986
  try {
1650
- const stat = fs2.statSync(filePath);
1987
+ const stat = fs3.statSync(filePath);
1651
1988
  size = stat.size;
1652
- const fd = fs2.openSync(filePath, "r");
1989
+ const fd = fs3.openSync(filePath, "r");
1653
1990
  const buf = Buffer.alloc(Math.min(size, 512));
1654
- fs2.readSync(fd, buf, 0, buf.length, 0);
1655
- fs2.closeSync(fd);
1991
+ fs3.readSync(fd, buf, 0, buf.length, 0);
1992
+ fs3.closeSync(fd);
1656
1993
  const snippet = buf.toString("utf-8");
1657
1994
  const turnMatch = snippet.match(/"turns"\s*:\s*\[/);
1658
1995
  if (turnMatch) {
1659
1996
  if (size < 1048576) {
1660
1997
  try {
1661
- const full = fs2.readFileSync(filePath, "utf-8");
1998
+ const full = fs3.readFileSync(filePath, "utf-8");
1662
1999
  const obj = JSON.parse(full);
1663
2000
  turnCount = obj.turns?.length ?? 0;
1664
2001
  } catch {
@@ -1692,7 +2029,7 @@ var CheckpointManager = class {
1692
2029
  for (const cp of toRemove) {
1693
2030
  try {
1694
2031
  const filePath = this.checkpointPath(sessionId, cp);
1695
- await fs2.promises.unlink(filePath);
2032
+ await fs3.promises.unlink(filePath);
1696
2033
  removed++;
1697
2034
  } catch {
1698
2035
  }
@@ -1731,24 +2068,24 @@ var CheckpointManager = class {
1731
2068
  */
1732
2069
  async deleteAll(sessionId) {
1733
2070
  const sessionDir = this.sessionDir(sessionId);
1734
- if (!fs2.existsSync(sessionDir)) return;
2071
+ if (!fs3.existsSync(sessionDir)) return;
1735
2072
  try {
1736
- await fs2.promises.rm(sessionDir, { recursive: true, force: true });
2073
+ await fs3.promises.rm(sessionDir, { recursive: true, force: true });
1737
2074
  } catch {
1738
2075
  }
1739
2076
  }
1740
2077
  // ─── Private ──────────────────────────────────────────────────────────────
1741
2078
  sessionDir(sessionId) {
1742
- return path2.join(this.dir, sessionId);
2079
+ return path3.join(this.dir, sessionId);
1743
2080
  }
1744
2081
  checkpointPath(sessionId, cp) {
1745
- return path2.join(this.sessionDir(sessionId), `${cp.id}${CHECKPOINT_EXT}`);
2082
+ return path3.join(this.sessionDir(sessionId), `${cp.id}${CHECKPOINT_EXT}`);
1746
2083
  }
1747
2084
  };
1748
2085
 
1749
2086
  // ../chitragupta/packages/smriti/src/consolidation.ts
1750
- import fs3 from "fs";
1751
- import path3 from "path";
2087
+ import fs4 from "fs";
2088
+ import path4 from "path";
1752
2089
  var DEFAULT_CONFIG = {
1753
2090
  minObservations: 2,
1754
2091
  decayRatePerDay: 0.01,
@@ -2036,11 +2373,11 @@ var ConsolidationEngine = class {
2036
2373
  */
2037
2374
  save() {
2038
2375
  const dir = this.getStoragePath();
2039
- fs3.mkdirSync(dir, { recursive: true });
2040
- const rulesPath = path3.join(dir, "rules.json");
2041
- const historyPath = path3.join(dir, "history.json");
2042
- fs3.writeFileSync(rulesPath, JSON.stringify(this.getRules(), null, " "), "utf-8");
2043
- fs3.writeFileSync(historyPath, JSON.stringify(this.history, null, " "), "utf-8");
2376
+ fs4.mkdirSync(dir, { recursive: true });
2377
+ const rulesPath = path4.join(dir, "rules.json");
2378
+ const historyPath = path4.join(dir, "history.json");
2379
+ fs4.writeFileSync(rulesPath, JSON.stringify(this.getRules(), null, " "), "utf-8");
2380
+ fs4.writeFileSync(historyPath, JSON.stringify(this.history, null, " "), "utf-8");
2044
2381
  }
2045
2382
  /**
2046
2383
  * Load previously persisted rules and history from disk.
@@ -2048,11 +2385,11 @@ var ConsolidationEngine = class {
2048
2385
  */
2049
2386
  load() {
2050
2387
  const dir = this.getStoragePath();
2051
- const rulesPath = path3.join(dir, "rules.json");
2052
- const historyPath = path3.join(dir, "history.json");
2053
- if (fs3.existsSync(rulesPath)) {
2388
+ const rulesPath = path4.join(dir, "rules.json");
2389
+ const historyPath = path4.join(dir, "history.json");
2390
+ if (fs4.existsSync(rulesPath)) {
2054
2391
  try {
2055
- const data = JSON.parse(fs3.readFileSync(rulesPath, "utf-8"));
2392
+ const data = JSON.parse(fs4.readFileSync(rulesPath, "utf-8"));
2056
2393
  this.rules.clear();
2057
2394
  for (const rule of data) {
2058
2395
  this.rules.set(rule.id, rule);
@@ -2063,10 +2400,10 @@ var ConsolidationEngine = class {
2063
2400
  this.rules.clear();
2064
2401
  }
2065
2402
  }
2066
- if (fs3.existsSync(historyPath)) {
2403
+ if (fs4.existsSync(historyPath)) {
2067
2404
  try {
2068
2405
  this.history = JSON.parse(
2069
- fs3.readFileSync(historyPath, "utf-8")
2406
+ fs4.readFileSync(historyPath, "utf-8")
2070
2407
  );
2071
2408
  } catch (err) {
2072
2409
  process.stderr.write(`[consolidation] corrupted history.json, starting fresh: ${err instanceof Error ? err.message : err}
@@ -2457,7 +2794,7 @@ var ConsolidationEngine = class {
2457
2794
  * @returns Absolute path to the consolidation storage directory.
2458
2795
  */
2459
2796
  getStoragePath() {
2460
- return this.config.storagePath ?? path3.join(getChitraguptaHome(), "consolidation");
2797
+ return this.config.storagePath ?? path4.join(getChitraguptaHome(), "consolidation");
2461
2798
  }
2462
2799
  };
2463
2800
  function extractSentenceContaining(text, index) {
@@ -3009,8 +3346,8 @@ var AnveshanaEngine = class {
3009
3346
  };
3010
3347
 
3011
3348
  // ../chitragupta/packages/smriti/src/smaran.ts
3012
- import fs4 from "fs";
3013
- import path4 from "path";
3349
+ import fs5 from "fs";
3350
+ import path5 from "path";
3014
3351
  var DEFAULT_CONFIG3 = {
3015
3352
  maxEntries: 1e3,
3016
3353
  defaultDecayDays: 90,
@@ -3039,7 +3376,7 @@ var SmaranStore = class {
3039
3376
  SMARAN_HARD_CEILINGS.recallLimit
3040
3377
  )
3041
3378
  };
3042
- this.storagePath = this.config.storagePath ?? path4.join(getChitraguptaHome(), "smaran");
3379
+ this.storagePath = this.config.storagePath ?? path5.join(getChitraguptaHome(), "smaran");
3043
3380
  }
3044
3381
  // ─── Core CRUD ────────────────────────────────────────────────────────
3045
3382
  /**
@@ -3308,11 +3645,11 @@ var SmaranStore = class {
3308
3645
  this.loaded = true;
3309
3646
  }
3310
3647
  loadAll() {
3311
- if (!fs4.existsSync(this.storagePath)) return;
3312
- const files = fs4.readdirSync(this.storagePath).filter((f) => f.endsWith(".md"));
3648
+ if (!fs5.existsSync(this.storagePath)) return;
3649
+ const files = fs5.readdirSync(this.storagePath).filter((f) => f.endsWith(".md"));
3313
3650
  for (const file of files) {
3314
3651
  try {
3315
- const content = fs4.readFileSync(path4.join(this.storagePath, file), "utf-8");
3652
+ const content = fs5.readFileSync(path5.join(this.storagePath, file), "utf-8");
3316
3653
  const entry = this.fromMarkdown(content);
3317
3654
  if (entry) {
3318
3655
  this.entries.set(entry.id, entry);
@@ -3327,15 +3664,15 @@ var SmaranStore = class {
3327
3664
  }
3328
3665
  }
3329
3666
  saveEntry(entry) {
3330
- fs4.mkdirSync(this.storagePath, { recursive: true });
3331
- const filePath = path4.join(this.storagePath, `${entry.id}.md`);
3667
+ fs5.mkdirSync(this.storagePath, { recursive: true });
3668
+ const filePath = path5.join(this.storagePath, `${entry.id}.md`);
3332
3669
  const content = this.toMarkdown(entry);
3333
- fs4.writeFileSync(filePath, content, { encoding: "utf-8", mode: 384 });
3670
+ fs5.writeFileSync(filePath, content, { encoding: "utf-8", mode: 384 });
3334
3671
  }
3335
3672
  deleteFile(id) {
3336
- const filePath = path4.join(this.storagePath, `${id}.md`);
3673
+ const filePath = path5.join(this.storagePath, `${id}.md`);
3337
3674
  try {
3338
- if (fs4.existsSync(filePath)) fs4.unlinkSync(filePath);
3675
+ if (fs5.existsSync(filePath)) fs5.unlinkSync(filePath);
3339
3676
  } catch {
3340
3677
  }
3341
3678
  }
@@ -3581,9 +3918,9 @@ function cleanContent(content) {
3581
3918
  }
3582
3919
 
3583
3920
  // ../chitragupta/packages/smriti/src/identity-context.ts
3584
- import fs5 from "fs";
3585
- import path5 from "path";
3586
- import os from "os";
3921
+ import fs6 from "fs";
3922
+ import path6 from "path";
3923
+ import os2 from "os";
3587
3924
  var DEFAULT_INCLUDE = ["soul", "identity", "personality", "user"];
3588
3925
  var FILE_NAMES = {
3589
3926
  soul: ["SOUL.md", "soul.md"],
@@ -3691,7 +4028,7 @@ var IdentityContext = class {
3691
4028
  const fileNames = FILE_NAMES[type];
3692
4029
  for (const dir of searchDirs) {
3693
4030
  for (const name of fileNames) {
3694
- const filePath = path5.join(dir, name);
4031
+ const filePath = path6.join(dir, name);
3695
4032
  const content = readFileSafe(filePath);
3696
4033
  if (content) return { type, path: filePath, content };
3697
4034
  }
@@ -3704,13 +4041,13 @@ var IdentityContext = class {
3704
4041
  dirs.push(this.config.projectPath);
3705
4042
  let current = this.config.projectPath;
3706
4043
  for (let i = 0; i < 3; i++) {
3707
- const parent = path5.dirname(current);
4044
+ const parent = path6.dirname(current);
3708
4045
  if (parent === current) break;
3709
4046
  dirs.push(parent);
3710
4047
  current = parent;
3711
4048
  }
3712
4049
  }
3713
- dirs.push(os.homedir());
4050
+ dirs.push(os2.homedir());
3714
4051
  return dirs;
3715
4052
  }
3716
4053
  typeLabel(type) {
@@ -3730,8 +4067,8 @@ var IdentityContext = class {
3730
4067
  };
3731
4068
  function readFileSafe(filePath) {
3732
4069
  try {
3733
- if (fs5.existsSync(filePath)) {
3734
- const content = fs5.readFileSync(filePath, "utf-8");
4070
+ if (fs6.existsSync(filePath)) {
4071
+ const content = fs6.readFileSync(filePath, "utf-8");
3735
4072
  if (content.trim().length > 0) return content;
3736
4073
  }
3737
4074
  } catch {
@@ -6932,16 +7269,16 @@ async function recall(query, options) {
6932
7269
  }
6933
7270
  async function searchHybrid(query, project, limit) {
6934
7271
  try {
6935
- const { HybridSearchEngine: HybridSearchEngine2 } = await import("./hybrid-search-6XMUT66S.js");
7272
+ const { HybridSearchEngine: HybridSearchEngine2 } = await import("./hybrid-search-TX6T3KYH.js");
6936
7273
  let recallEngine = null;
6937
7274
  let graphEngine = null;
6938
7275
  try {
6939
- const { RecallEngine: RecallEngine2 } = await import("./recall-THTI6ZO2.js");
7276
+ const { RecallEngine: RecallEngine2 } = await import("./recall-IUPQCBYP.js");
6940
7277
  recallEngine = new RecallEngine2();
6941
7278
  } catch {
6942
7279
  }
6943
7280
  try {
6944
- const { GraphRAGEngine: GraphRAGEngine2 } = await import("./graphrag-6YZ5YPLK.js");
7281
+ const { GraphRAGEngine: GraphRAGEngine2 } = await import("./graphrag-LAZSXLLI.js");
6945
7282
  graphEngine = new GraphRAGEngine2();
6946
7283
  } catch {
6947
7284
  }
@@ -6979,8 +7316,8 @@ async function searchHybrid(query, project, limit) {
6979
7316
  }
6980
7317
  async function searchTurns(query, project) {
6981
7318
  try {
6982
- const { searchSessions: searchSessions2 } = await import("./search-V7DJ3VNL.js");
6983
- const { loadSession: loadSession2 } = await import("./session-store-GRKGTMHI.js");
7319
+ const { searchSessions: searchSessions2 } = await import("./search-HHSVHBXC.js");
7320
+ const { loadSession: loadSession2 } = await import("./session-store-NDUDYAC7.js");
6984
7321
  const metas = searchSessions2(query, project);
6985
7322
  const results = [];
6986
7323
  for (const meta of metas.slice(0, 10)) {
@@ -7026,7 +7363,7 @@ async function searchTurns(query, project) {
7026
7363
  }
7027
7364
  async function searchMemoryLayer(query) {
7028
7365
  try {
7029
- const { searchMemory: searchMemory2 } = await import("./search-V7DJ3VNL.js");
7366
+ const { searchMemory: searchMemory2 } = await import("./search-HHSVHBXC.js");
7030
7367
  const results = searchMemory2(query);
7031
7368
  return results.slice(0, 5).map((r) => ({
7032
7369
  score: Math.min((r.relevance ?? 0.5) + 0.1, 1),
@@ -7040,7 +7377,7 @@ async function searchMemoryLayer(query) {
7040
7377
  }
7041
7378
  async function searchDayFileLayer(query, limit) {
7042
7379
  try {
7043
- const { hierarchicalTemporalSearch: hierarchicalTemporalSearch2 } = await import("./hierarchical-temporal-search-VA4D3SON.js");
7380
+ const { hierarchicalTemporalSearch: hierarchicalTemporalSearch2 } = await import("./hierarchical-temporal-search-ETXYYJZK.js");
7044
7381
  const results = await hierarchicalTemporalSearch2(query, { limit });
7045
7382
  if (results.length > 0) {
7046
7383
  return results.map((r) => ({
@@ -7055,7 +7392,7 @@ async function searchDayFileLayer(query, limit) {
7055
7392
  } catch {
7056
7393
  }
7057
7394
  try {
7058
- const { searchDayFiles: searchDayFiles2 } = await import("./day-consolidation-GQ2FDCR2.js");
7395
+ const { searchDayFiles: searchDayFiles2 } = await import("./day-consolidation-U3X6P4ZG.js");
7059
7396
  const results = searchDayFiles2(query, { limit });
7060
7397
  return results.map((r) => ({
7061
7398
  score: 0.5,
@@ -7086,7 +7423,7 @@ async function loadProviderContext(project, options) {
7086
7423
  let projectMemory = "";
7087
7424
  let recentContext = "";
7088
7425
  try {
7089
- const { getMemory: getMemory2 } = await import("./memory-store-KNJPMBLQ.js");
7426
+ const { getMemory: getMemory2 } = await import("./memory-store-A6WOWLWC.js");
7090
7427
  globalFacts = getMemory2({ type: "global" });
7091
7428
  if (globalFacts.length > maxLen / 3) {
7092
7429
  globalFacts = globalFacts.slice(0, maxLen / 3) + "\n...(truncated)";
@@ -7095,7 +7432,7 @@ async function loadProviderContext(project, options) {
7095
7432
  }
7096
7433
  if (project) {
7097
7434
  try {
7098
- const { getMemory: getMemory2 } = await import("./memory-store-KNJPMBLQ.js");
7435
+ const { getMemory: getMemory2 } = await import("./memory-store-A6WOWLWC.js");
7099
7436
  projectMemory = getMemory2({ type: "project", path: project });
7100
7437
  if (projectMemory.length > maxLen / 3) {
7101
7438
  projectMemory = projectMemory.slice(0, maxLen / 3) + "\n...(truncated)";
@@ -7105,7 +7442,7 @@ async function loadProviderContext(project, options) {
7105
7442
  }
7106
7443
  let vasanaContext = "";
7107
7444
  try {
7108
- const { VasanaEngine: VasanaEngine2 } = await import("./vasana-engine-Z4RXW2SB.js");
7445
+ const { VasanaEngine: VasanaEngine2 } = await import("./vasana-engine-G6BPOFX7.js");
7109
7446
  const engine = new VasanaEngine2();
7110
7447
  const vasanas = engine.getVasanas(project ?? "__global__", 5);
7111
7448
  if (vasanas.length > 0) {
@@ -7116,7 +7453,7 @@ async function loadProviderContext(project, options) {
7116
7453
  } catch {
7117
7454
  }
7118
7455
  try {
7119
- const { listSessions: listSessions2, loadSession: loadSession2 } = await import("./session-store-GRKGTMHI.js");
7456
+ const { listSessions: listSessions2, loadSession: loadSession2 } = await import("./session-store-NDUDYAC7.js");
7120
7457
  const sessions = project ? listSessions2(project).slice(0, recentLimit) : listSessions2().slice(0, recentLimit);
7121
7458
  const summaries = [];
7122
7459
  for (const meta of sessions) {
@@ -7169,6 +7506,11 @@ export {
7169
7506
  exportSessionToMarkdown,
7170
7507
  importSessionFromJson,
7171
7508
  detectExportFormat,
7509
+ createCrossMachineSnapshot,
7510
+ writeCrossMachineSnapshot,
7511
+ readCrossMachineSnapshot,
7512
+ getCrossMachineSyncStatus,
7513
+ importCrossMachineSnapshot,
7172
7514
  branchSession,
7173
7515
  getSessionTree,
7174
7516
  sinkhornKnopp,
@@ -7203,4 +7545,4 @@ export {
7203
7545
  recall,
7204
7546
  loadProviderContext
7205
7547
  };
7206
- //# sourceMappingURL=chunk-5Z2BKSFF.js.map
7548
+ //# sourceMappingURL=chunk-YSC77CKZ.js.map