teleton 0.8.4 → 0.8.5

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 (40) hide show
  1. package/README.md +16 -12
  2. package/dist/{bootstrap-NNEI3Z5H.js → bootstrap-SPDT3XBQ.js} +4 -4
  3. package/dist/{chunk-GHMXWAXI.js → chunk-2MZP75SH.js} +72 -202
  4. package/dist/chunk-35X3V6OW.js +139 -0
  5. package/dist/{chunk-LVTKJQ7O.js → chunk-4KURCUWD.js} +1 -1
  6. package/dist/{chunk-XDZDOKIF.js → chunk-5K4YDCVU.js} +1 -1
  7. package/dist/{chunk-LZQOX6YY.js → chunk-6U6VA2OT.js} +512 -1522
  8. package/dist/{chunk-5LOHRZYY.js → chunk-7ZXUUDQQ.js} +5 -5
  9. package/dist/{chunk-NH2CNRKJ.js → chunk-FSL2MOYK.js} +14 -3
  10. package/dist/{chunk-LC4TV3KL.js → chunk-GUX6ZFVF.js} +1 -1
  11. package/dist/{chunk-CUE4UZXR.js → chunk-KYSAHDYE.js} +2 -2
  12. package/dist/{chunk-C4NKJT2Z.js → chunk-L3LPVF4Z.js} +1 -1
  13. package/dist/{chunk-EYWNOHMJ.js → chunk-L653KKCR.js} +1 -0
  14. package/dist/{chunk-ALKAAG4O.js → chunk-LD24DWWE.js} +4 -4
  15. package/dist/{chunk-UMUONAD6.js → chunk-LM6AL6LN.js} +2413 -861
  16. package/dist/{chunk-JROBTXWY.js → chunk-M6M4DCDU.js} +36 -2
  17. package/dist/{chunk-35MX4ZUI.js → chunk-PK3TVFBT.js} +2 -2
  18. package/dist/{chunk-G7PCW63M.js → chunk-Z63KUQX4.js} +29 -5
  19. package/dist/cli/index.js +28 -15
  20. package/dist/{client-5KD25NOP.js → client-G62EZT6U.js} +3 -3
  21. package/dist/harden-permissions-6BLHRCQJ.js +100 -0
  22. package/dist/index.js +14 -13
  23. package/dist/{local-IHKJFQJS.js → local-HQ3UJ7KR.js} +2 -2
  24. package/dist/{memory-QMJRM3XJ.js → memory-BJH724PQ.js} +6 -5
  25. package/dist/{memory-hook-VUNWZ3NY.js → memory-hook-LUAKTXU5.js} +5 -5
  26. package/dist/{migrate-5VBAP52B.js → migrate-C4LBLOZH.js} +6 -5
  27. package/dist/{paths-XA2RJH4S.js → paths-WMVV7ZAJ.js} +1 -1
  28. package/dist/{server-WWGVDFPW.js → server-4J56HS62.js} +8 -14
  29. package/dist/{server-AJCOURH7.js → server-I6TYJ36S.js} +7 -14
  30. package/dist/{setup-server-VDY64CWW.js → setup-server-VJ3MGUSM.js} +16 -17
  31. package/dist/{store-BY7S6IFN.js → store-2IGAMTES.js} +7 -6
  32. package/dist/{task-dependency-resolver-L6UUMTHK.js → task-dependency-resolver-CQ432Z7J.js} +1 -1
  33. package/dist/{task-executor-XBNJLUCS.js → task-executor-JELRREUV.js} +1 -1
  34. package/dist/{tool-index-FTERJSZK.js → tool-index-XPCMWBYY.js} +4 -4
  35. package/dist/{transcript-IM7G25OS.js → transcript-OEO3HA4Z.js} +2 -2
  36. package/dist/web/assets/{index-BfYCdwLI.js → index-Dn5ZH1Y6.js} +13 -13
  37. package/dist/web/assets/{index.es-DitvF-9H.js → index.es-eSR4Qv6s.js} +1 -1
  38. package/dist/web/index.html +1 -1
  39. package/package.json +2 -6
  40. package/src/templates/HEARTBEAT.md +5 -0
@@ -1,9 +1,12 @@
1
+ import {
2
+ JOURNAL_SCHEMA
3
+ } from "./chunk-35X3V6OW.js";
1
4
  import {
2
5
  CachedEmbeddingProvider,
3
6
  createEmbeddingProvider,
4
7
  hashText,
5
8
  serializeEmbedding
6
- } from "./chunk-35MX4ZUI.js";
9
+ } from "./chunk-PK3TVFBT.js";
7
10
  import {
8
11
  FEED_MESSAGE_MAX_CHARS,
9
12
  HYBRID_SEARCH_MIN_SCORE,
@@ -14,147 +17,19 @@ import {
14
17
  SECONDS_PER_HOUR,
15
18
  SQLITE_CACHE_SIZE_KB,
16
19
  SQLITE_MMAP_SIZE
17
- } from "./chunk-C4NKJT2Z.js";
18
- import {
19
- TELETON_ROOT
20
- } from "./chunk-EYWNOHMJ.js";
20
+ } from "./chunk-L3LPVF4Z.js";
21
21
  import {
22
22
  createLogger
23
23
  } from "./chunk-NQ6FZKCE.js";
24
24
 
25
25
  // src/memory/database.ts
26
- import Database2 from "better-sqlite3";
27
- import { existsSync as existsSync2, mkdirSync as mkdirSync2, chmodSync as chmodSync2 } from "fs";
28
- import { dirname as dirname2 } from "path";
29
- import * as sqliteVec from "sqlite-vec";
30
-
31
- // src/utils/module-db.ts
32
26
  import Database from "better-sqlite3";
33
27
  import { existsSync, mkdirSync, chmodSync } from "fs";
34
- import { dirname, join } from "path";
35
- var log = createLogger("Utils");
36
- var JOURNAL_SCHEMA = `
37
- CREATE TABLE IF NOT EXISTS journal (
38
- id INTEGER PRIMARY KEY AUTOINCREMENT,
39
- timestamp INTEGER NOT NULL DEFAULT (unixepoch()),
40
- type TEXT NOT NULL CHECK(type IN ('trade', 'gift', 'middleman', 'kol')),
41
- action TEXT NOT NULL,
42
- asset_from TEXT,
43
- asset_to TEXT,
44
- amount_from REAL,
45
- amount_to REAL,
46
- price_ton REAL,
47
- counterparty TEXT,
48
- platform TEXT,
49
- reasoning TEXT,
50
- outcome TEXT CHECK(outcome IN ('pending', 'profit', 'loss', 'neutral', 'cancelled')),
51
- pnl_ton REAL,
52
- pnl_pct REAL,
53
- tx_hash TEXT,
54
- tool_used TEXT,
55
- chat_id TEXT,
56
- user_id INTEGER,
57
- closed_at INTEGER,
58
- created_at INTEGER NOT NULL DEFAULT (unixepoch())
59
- );
60
-
61
- CREATE INDEX IF NOT EXISTS idx_journal_type ON journal(type);
62
- CREATE INDEX IF NOT EXISTS idx_journal_timestamp ON journal(timestamp DESC);
63
- CREATE INDEX IF NOT EXISTS idx_journal_asset_from ON journal(asset_from);
64
- CREATE INDEX IF NOT EXISTS idx_journal_outcome ON journal(outcome);
65
- CREATE INDEX IF NOT EXISTS idx_journal_type_timestamp ON journal(type, timestamp DESC);
66
- `;
67
- var USED_TRANSACTIONS_SCHEMA = `
68
- CREATE TABLE IF NOT EXISTS used_transactions (
69
- tx_hash TEXT PRIMARY KEY,
70
- user_id TEXT NOT NULL,
71
- amount REAL NOT NULL,
72
- game_type TEXT NOT NULL,
73
- used_at INTEGER NOT NULL DEFAULT (unixepoch())
74
- );
75
-
76
- CREATE INDEX IF NOT EXISTS idx_used_tx_user ON used_transactions(user_id);
77
- CREATE INDEX IF NOT EXISTS idx_used_tx_used_at ON used_transactions(used_at);
78
- `;
79
- function openModuleDb(path) {
80
- const dir = dirname(path);
81
- if (!existsSync(dir)) {
82
- mkdirSync(dir, { recursive: true });
83
- }
84
- const db = new Database(path);
85
- try {
86
- chmodSync(path, 384);
87
- } catch {
88
- }
89
- db.pragma("journal_mode = WAL");
90
- return db;
91
- }
92
- function createDbWrapper(getDb, moduleName) {
93
- return function withDb(executor) {
94
- return (params, context) => {
95
- const moduleDb = getDb();
96
- if (!moduleDb) {
97
- return Promise.resolve({
98
- success: false,
99
- error: `${moduleName} module not started`
100
- });
101
- }
102
- return executor(params, { ...context, db: moduleDb });
103
- };
104
- };
105
- }
106
- var MAIN_DB_PATH = join(TELETON_ROOT, "memory.db");
107
- function migrateFromMainDb(moduleDb, tables) {
108
- let totalMigrated = 0;
109
- for (const table of tables) {
110
- if (!/^[a-z_]+$/.test(table)) {
111
- throw new Error(`Invalid table name for migration: "${table}"`);
112
- }
113
- }
114
- for (const table of tables) {
115
- try {
116
- const row = moduleDb.prepare(`SELECT COUNT(*) as c FROM ${table}`).get();
117
- if (row.c > 0) return 0;
118
- } catch {
119
- continue;
120
- }
121
- }
122
- if (!existsSync(MAIN_DB_PATH)) return 0;
123
- try {
124
- moduleDb.exec(`ATTACH DATABASE '${MAIN_DB_PATH}' AS main_db`);
125
- for (const table of tables) {
126
- try {
127
- const exists = moduleDb.prepare(`SELECT name FROM main_db.sqlite_master WHERE type='table' AND name=?`).get(table);
128
- if (!exists) continue;
129
- const src = moduleDb.prepare(`SELECT COUNT(*) as c FROM main_db.${table}`).get();
130
- if (src.c === 0) continue;
131
- const dstCols = moduleDb.prepare(`PRAGMA table_info(${table})`).all().map((r) => r.name);
132
- const srcCols = moduleDb.prepare(`PRAGMA main_db.table_info(${table})`).all().map((r) => r.name);
133
- const shared = dstCols.filter((c) => srcCols.includes(c));
134
- if (shared.length === 0) continue;
135
- const cols = shared.join(", ");
136
- moduleDb.exec(
137
- `INSERT OR IGNORE INTO ${table} (${cols}) SELECT ${cols} FROM main_db.${table}`
138
- );
139
- totalMigrated += src.c;
140
- log.info(`Migrated ${src.c} rows from memory.db \u2192 ${table}`);
141
- } catch (e) {
142
- log.warn({ err: e }, `Could not migrate table ${table}`);
143
- }
144
- }
145
- moduleDb.exec(`DETACH DATABASE main_db`);
146
- } catch (e) {
147
- log.warn({ err: e }, `Migration from memory.db failed`);
148
- try {
149
- moduleDb.exec(`DETACH DATABASE main_db`);
150
- } catch {
151
- }
152
- }
153
- return totalMigrated;
154
- }
28
+ import { dirname } from "path";
29
+ import * as sqliteVec from "sqlite-vec";
155
30
 
156
31
  // src/memory/schema.ts
157
- var log2 = createLogger("Memory");
32
+ var log = createLogger("Memory");
158
33
  function compareSemver(a, b) {
159
34
  const parseVersion = (v) => {
160
35
  const parts = v.split("-")[0].split(".").map(Number);
@@ -496,11 +371,11 @@ var CURRENT_SCHEMA_VERSION = "1.15.0";
496
371
  function runMigrations(db) {
497
372
  const currentVersion = getSchemaVersion(db);
498
373
  if (!currentVersion || versionLessThan(currentVersion, "1.1.0")) {
499
- log2.info("Running migration: Adding scheduled task columns...");
374
+ log.info("Running migration: Adding scheduled task columns...");
500
375
  try {
501
376
  const tableExists = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='tasks'").get();
502
377
  if (!tableExists) {
503
- log2.info("Tasks table doesn't exist yet, skipping column migration");
378
+ log.info("Tasks table doesn't exist yet, skipping column migration");
504
379
  setSchemaVersion(db, CURRENT_SCHEMA_VERSION);
505
380
  return;
506
381
  }
@@ -533,15 +408,15 @@ function runMigrations(db) {
533
408
  CREATE INDEX IF NOT EXISTS idx_task_deps_task ON task_dependencies(task_id);
534
409
  CREATE INDEX IF NOT EXISTS idx_task_deps_parent ON task_dependencies(depends_on_task_id);
535
410
  `);
536
- log2.info("Migration 1.1.0 complete: Scheduled tasks support added");
411
+ log.info("Migration 1.1.0 complete: Scheduled tasks support added");
537
412
  } catch (error) {
538
- log2.error({ err: error }, "Migration 1.1.0 failed");
413
+ log.error({ err: error }, "Migration 1.1.0 failed");
539
414
  throw error;
540
415
  }
541
416
  }
542
417
  if (!currentVersion || versionLessThan(currentVersion, "1.2.0")) {
543
418
  try {
544
- log2.info("Running migration 1.2.0: Extend sessions table for SQLite backend");
419
+ log.info("Running migration 1.2.0: Extend sessions table for SQLite backend");
545
420
  const addColumnIfNotExists = (table, column, type) => {
546
421
  try {
547
422
  db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${type}`);
@@ -570,14 +445,14 @@ function runMigrations(db) {
570
445
  );
571
446
  }
572
447
  db.exec("CREATE INDEX IF NOT EXISTS idx_sessions_updated ON sessions(updated_at DESC)");
573
- log2.info("Migration 1.2.0 complete: Sessions table extended");
448
+ log.info("Migration 1.2.0 complete: Sessions table extended");
574
449
  } catch (error) {
575
- log2.error({ err: error }, "Migration 1.2.0 failed");
450
+ log.error({ err: error }, "Migration 1.2.0 failed");
576
451
  throw error;
577
452
  }
578
453
  }
579
454
  if (!currentVersion || versionLessThan(currentVersion, "1.9.0")) {
580
- log2.info("Running migration 1.9.0: Upgrade embedding_cache to BLOB storage");
455
+ log.info("Running migration 1.9.0: Upgrade embedding_cache to BLOB storage");
581
456
  try {
582
457
  db.exec(`DROP TABLE IF EXISTS embedding_cache`);
583
458
  db.exec(`
@@ -593,14 +468,14 @@ function runMigrations(db) {
593
468
  );
594
469
  CREATE INDEX IF NOT EXISTS idx_embedding_cache_accessed ON embedding_cache(accessed_at);
595
470
  `);
596
- log2.info("Migration 1.9.0 complete: embedding_cache upgraded to BLOB storage");
471
+ log.info("Migration 1.9.0 complete: embedding_cache upgraded to BLOB storage");
597
472
  } catch (error) {
598
- log2.error({ err: error }, "Migration 1.9.0 failed");
473
+ log.error({ err: error }, "Migration 1.9.0 failed");
599
474
  throw error;
600
475
  }
601
476
  }
602
477
  if (!currentVersion || versionLessThan(currentVersion, "1.10.0")) {
603
- log2.info("Running migration 1.10.0: Add tool_config table for runtime tool management");
478
+ log.info("Running migration 1.10.0: Add tool_config table for runtime tool management");
604
479
  try {
605
480
  db.exec(`
606
481
  CREATE TABLE IF NOT EXISTS tool_config (
@@ -611,14 +486,14 @@ function runMigrations(db) {
611
486
  updated_by INTEGER
612
487
  );
613
488
  `);
614
- log2.info("Migration 1.10.0 complete: tool_config table created");
489
+ log.info("Migration 1.10.0 complete: tool_config table created");
615
490
  } catch (error) {
616
- log2.error({ err: error }, "Migration 1.10.0 failed");
491
+ log.error({ err: error }, "Migration 1.10.0 failed");
617
492
  throw error;
618
493
  }
619
494
  }
620
495
  if (!currentVersion || versionLessThan(currentVersion, "1.10.1")) {
621
- log2.info("Running migration 1.10.1: Fix tool_config scope CHECK constraint (add admin-only)");
496
+ log.info("Running migration 1.10.1: Fix tool_config scope CHECK constraint (add admin-only)");
622
497
  try {
623
498
  db.transaction(() => {
624
499
  db.exec(`
@@ -634,14 +509,14 @@ function runMigrations(db) {
634
509
  ALTER TABLE tool_config_new RENAME TO tool_config;
635
510
  `);
636
511
  })();
637
- log2.info("Migration 1.10.1 complete: tool_config CHECK constraint updated");
512
+ log.info("Migration 1.10.1 complete: tool_config CHECK constraint updated");
638
513
  } catch (error) {
639
- log2.error({ err: error }, "Migration 1.10.1 failed");
514
+ log.error({ err: error }, "Migration 1.10.1 failed");
640
515
  throw error;
641
516
  }
642
517
  }
643
518
  if (!currentVersion || versionLessThan(currentVersion, "1.11.0")) {
644
- log2.info("Running migration 1.11.0: Add tool_index tables for Tool RAG");
519
+ log.info("Running migration 1.11.0: Add tool_index tables for Tool RAG");
645
520
  try {
646
521
  db.exec(`
647
522
  CREATE TABLE IF NOT EXISTS tool_index (
@@ -673,14 +548,14 @@ function runMigrations(db) {
673
548
  VALUES (new.rowid, new.search_text, new.name);
674
549
  END;
675
550
  `);
676
- log2.info("Migration 1.11.0 complete: tool_index tables created");
551
+ log.info("Migration 1.11.0 complete: tool_index tables created");
677
552
  } catch (error) {
678
- log2.error({ err: error }, "Migration 1.11.0 failed");
553
+ log.error({ err: error }, "Migration 1.11.0 failed");
679
554
  throw error;
680
555
  }
681
556
  }
682
557
  if (!currentVersion || versionLessThan(currentVersion, "1.12.0")) {
683
- log2.info("Running migration 1.12.0: Add exec_audit table");
558
+ log.info("Running migration 1.12.0: Add exec_audit table");
684
559
  try {
685
560
  db.exec(`
686
561
  CREATE TABLE IF NOT EXISTS exec_audit (
@@ -702,14 +577,14 @@ function runMigrations(db) {
702
577
  CREATE INDEX IF NOT EXISTS idx_exec_audit_timestamp ON exec_audit(timestamp DESC);
703
578
  CREATE INDEX IF NOT EXISTS idx_exec_audit_user ON exec_audit(user_id);
704
579
  `);
705
- log2.info("Migration 1.12.0 complete: exec_audit table created");
580
+ log.info("Migration 1.12.0 complete: exec_audit table created");
706
581
  } catch (error) {
707
- log2.error({ err: error }, "Migration 1.12.0 failed");
582
+ log.error({ err: error }, "Migration 1.12.0 failed");
708
583
  throw error;
709
584
  }
710
585
  }
711
586
  if (!currentVersion || versionLessThan(currentVersion, "1.13.0")) {
712
- log2.info("Running migration 1.13.0: Add token usage columns to sessions");
587
+ log.info("Running migration 1.13.0: Add token usage columns to sessions");
713
588
  try {
714
589
  const addColumnIfNotExists = (table, column, type) => {
715
590
  try {
@@ -722,14 +597,14 @@ function runMigrations(db) {
722
597
  };
723
598
  addColumnIfNotExists("sessions", "input_tokens", "INTEGER DEFAULT 0");
724
599
  addColumnIfNotExists("sessions", "output_tokens", "INTEGER DEFAULT 0");
725
- log2.info("Migration 1.13.0 complete: Token usage columns added to sessions");
600
+ log.info("Migration 1.13.0 complete: Token usage columns added to sessions");
726
601
  } catch (error) {
727
- log2.error({ err: error }, "Migration 1.13.0 failed");
602
+ log.error({ err: error }, "Migration 1.13.0 failed");
728
603
  throw error;
729
604
  }
730
605
  }
731
606
  if (!currentVersion || versionLessThan(currentVersion, "1.14.0")) {
732
- log2.info("Running migration 1.14.0: Add plugin_config table for plugin priority");
607
+ log.info("Running migration 1.14.0: Add plugin_config table for plugin priority");
733
608
  try {
734
609
  db.exec(`
735
610
  CREATE TABLE IF NOT EXISTS plugin_config (
@@ -738,14 +613,14 @@ function runMigrations(db) {
738
613
  updated_at TEXT NOT NULL DEFAULT (datetime('now'))
739
614
  );
740
615
  `);
741
- log2.info("Migration 1.14.0 complete: plugin_config table created");
616
+ log.info("Migration 1.14.0 complete: plugin_config table created");
742
617
  } catch (error) {
743
- log2.error({ err: error }, "Migration 1.14.0 failed");
618
+ log.error({ err: error }, "Migration 1.14.0 failed");
744
619
  throw error;
745
620
  }
746
621
  }
747
622
  if (!currentVersion || versionLessThan(currentVersion, "1.15.0")) {
748
- log2.info("Running migration 1.15.0: Add user_hook_config table");
623
+ log.info("Running migration 1.15.0: Add user_hook_config table");
749
624
  try {
750
625
  db.exec(`
751
626
  CREATE TABLE IF NOT EXISTS user_hook_config (
@@ -754,9 +629,9 @@ function runMigrations(db) {
754
629
  updated_at TEXT NOT NULL DEFAULT (datetime('now'))
755
630
  );
756
631
  `);
757
- log2.info("Migration 1.15.0 complete: user_hook_config table created");
632
+ log.info("Migration 1.15.0 complete: user_hook_config table created");
758
633
  } catch (error) {
759
- log2.error({ err: error }, "Migration 1.15.0 failed");
634
+ log.error({ err: error }, "Migration 1.15.0 failed");
760
635
  throw error;
761
636
  }
762
637
  }
@@ -764,7 +639,7 @@ function runMigrations(db) {
764
639
  }
765
640
 
766
641
  // src/memory/database.ts
767
- var log3 = createLogger("Memory");
642
+ var log2 = createLogger("Memory");
768
643
  var MemoryDatabase = class {
769
644
  db;
770
645
  config;
@@ -772,17 +647,17 @@ var MemoryDatabase = class {
772
647
  _dimensionsChanged = false;
773
648
  constructor(config) {
774
649
  this.config = config;
775
- const dir = dirname2(config.path);
776
- if (!existsSync2(dir)) {
777
- mkdirSync2(dir, { recursive: true });
650
+ const dir = dirname(config.path);
651
+ if (!existsSync(dir)) {
652
+ mkdirSync(dir, { recursive: true });
778
653
  }
779
- this.db = new Database2(config.path, {
780
- verbose: process.env.DEBUG_SQL ? (msg) => log3.debug(String(msg)) : void 0
654
+ this.db = new Database(config.path, {
655
+ verbose: process.env.DEBUG_SQL ? (msg) => log2.debug(String(msg)) : void 0
781
656
  });
782
657
  try {
783
- chmodSync2(config.path, 384);
658
+ chmodSync(config.path, 384);
784
659
  } catch (err) {
785
- log3.warn({ err, path: config.path }, "Failed to set DB file permissions to 0o600");
660
+ log2.warn({ err, path: config.path }, "Failed to set DB file permissions to 0o600");
786
661
  }
787
662
  this.db.pragma("journal_mode = WAL");
788
663
  this.db.pragma("synchronous = NORMAL");
@@ -797,7 +672,7 @@ var MemoryDatabase = class {
797
672
  try {
798
673
  currentVersion = getSchemaVersion(this.db);
799
674
  } catch (err) {
800
- log3.warn({ err }, "Could not read schema version, assuming fresh database");
675
+ log2.warn({ err }, "Could not read schema version, assuming fresh database");
801
676
  currentVersion = null;
802
677
  }
803
678
  if (!currentVersion) {
@@ -819,16 +694,16 @@ var MemoryDatabase = class {
819
694
  this._dimensionsChanged = ensureVectorTables(this.db, dims);
820
695
  this.vectorReady = true;
821
696
  } catch (error) {
822
- log3.warn(`sqlite-vec not available, vector search disabled: ${error.message}`);
823
- log3.warn("Falling back to keyword-only search");
697
+ log2.warn(`sqlite-vec not available, vector search disabled: ${error.message}`);
698
+ log2.warn("Falling back to keyword-only search");
824
699
  this.config.enableVectorSearch = false;
825
700
  }
826
701
  }
827
702
  migrate(from, to) {
828
- log3.info(`Migrating database from ${from} to ${to}...`);
703
+ log2.info(`Migrating database from ${from} to ${to}...`);
829
704
  runMigrations(this.db);
830
705
  ensureSchema(this.db);
831
- log3.info("Migration complete");
706
+ log2.info("Migration complete");
832
707
  }
833
708
  getDb() {
834
709
  return this.db;
@@ -936,8 +811,8 @@ function closeDatabase() {
936
811
  }
937
812
 
938
813
  // src/memory/agent/knowledge.ts
939
- import { readFileSync, existsSync as existsSync3, readdirSync, statSync } from "fs";
940
- import { join as join2 } from "path";
814
+ import { readFileSync, existsSync as existsSync2, readdirSync, statSync } from "fs";
815
+ import { join } from "path";
941
816
  var KnowledgeIndexer = class {
942
817
  constructor(db, workspaceDir, embedder, vectorEnabled) {
943
818
  this.db = db;
@@ -960,7 +835,7 @@ var KnowledgeIndexer = class {
960
835
  return { indexed, skipped };
961
836
  }
962
837
  async indexFile(absPath, force) {
963
- if (!existsSync3(absPath) || !absPath.endsWith(".md")) {
838
+ if (!existsSync2(absPath) || !absPath.endsWith(".md")) {
964
839
  return false;
965
840
  }
966
841
  const content = readFileSync(absPath, "utf-8");
@@ -1010,15 +885,15 @@ var KnowledgeIndexer = class {
1010
885
  }
1011
886
  listMemoryFiles() {
1012
887
  const files = [];
1013
- const memoryMd = join2(this.workspaceDir, "MEMORY.md");
1014
- if (existsSync3(memoryMd)) {
888
+ const memoryMd = join(this.workspaceDir, "MEMORY.md");
889
+ if (existsSync2(memoryMd)) {
1015
890
  files.push(memoryMd);
1016
891
  }
1017
- const memoryDir = join2(this.workspaceDir, "memory");
1018
- if (existsSync3(memoryDir)) {
892
+ const memoryDir = join(this.workspaceDir, "memory");
893
+ if (existsSync2(memoryDir)) {
1019
894
  const entries = readdirSync(memoryDir);
1020
895
  for (const entry of entries) {
1021
- const absPath = join2(memoryDir, entry);
896
+ const absPath = join(memoryDir, entry);
1022
897
  if (statSync(absPath).isFile() && entry.endsWith(".md")) {
1023
898
  files.push(absPath);
1024
899
  }
@@ -1088,7 +963,7 @@ var KnowledgeIndexer = class {
1088
963
 
1089
964
  // src/memory/agent/sessions.ts
1090
965
  import { randomUUID } from "crypto";
1091
- var log4 = createLogger("Memory");
966
+ var log3 = createLogger("Memory");
1092
967
  var SessionStore = class {
1093
968
  constructor(db, embedder, vectorEnabled) {
1094
969
  this.db = db;
@@ -1212,9 +1087,9 @@ ${session.summary}`;
1212
1087
  this.db.prepare(`DELETE FROM knowledge_vec WHERE id = ?`).run(knowledgeId);
1213
1088
  this.db.prepare(`INSERT INTO knowledge_vec (id, embedding) VALUES (?, ?)`).run(knowledgeId, embeddingBuffer);
1214
1089
  }
1215
- log4.info(`Indexed session ${sessionId} to knowledge base`);
1090
+ log3.info(`Indexed session ${sessionId} to knowledge base`);
1216
1091
  } catch (error) {
1217
- log4.error({ err: error }, "Error indexing session");
1092
+ log3.error({ err: error }, "Error indexing session");
1218
1093
  }
1219
1094
  }
1220
1095
  deleteSession(sessionId) {
@@ -1579,7 +1454,7 @@ var UserStore = class {
1579
1454
  };
1580
1455
 
1581
1456
  // src/memory/search/hybrid.ts
1582
- var log5 = createLogger("Memory");
1457
+ var log4 = createLogger("Memory");
1583
1458
  var UNIT_SECONDS = {
1584
1459
  hour: SECONDS_PER_HOUR,
1585
1460
  day: SECONDS_PER_DAY,
@@ -1665,7 +1540,7 @@ var HybridSearch = class {
1665
1540
  createdAt: row.created_at ?? void 0
1666
1541
  }));
1667
1542
  } catch (error) {
1668
- log5.error({ err: error }, "Vector search error (knowledge)");
1543
+ log4.error({ err: error }, "Vector search error (knowledge)");
1669
1544
  return [];
1670
1545
  }
1671
1546
  }
@@ -1689,7 +1564,7 @@ var HybridSearch = class {
1689
1564
  createdAt: row.created_at ?? void 0
1690
1565
  }));
1691
1566
  } catch (error) {
1692
- log5.error({ err: error }, "FTS5 search error (knowledge)");
1567
+ log4.error({ err: error }, "FTS5 search error (knowledge)");
1693
1568
  return [];
1694
1569
  }
1695
1570
  }
@@ -1728,7 +1603,7 @@ var HybridSearch = class {
1728
1603
  createdAt: row.timestamp ?? void 0
1729
1604
  }));
1730
1605
  } catch (error) {
1731
- log5.error({ err: error }, "Vector search error (messages)");
1606
+ log4.error({ err: error }, "Vector search error (messages)");
1732
1607
  return [];
1733
1608
  }
1734
1609
  }
@@ -1763,7 +1638,7 @@ var HybridSearch = class {
1763
1638
  createdAt: row.timestamp ?? void 0
1764
1639
  }));
1765
1640
  } catch (error) {
1766
- log5.error({ err: error }, "FTS5 search error (messages)");
1641
+ log4.error({ err: error }, "FTS5 search error (messages)");
1767
1642
  return [];
1768
1643
  }
1769
1644
  }
@@ -1802,7 +1677,7 @@ var HybridSearch = class {
1802
1677
  };
1803
1678
 
1804
1679
  // src/memory/search/context.ts
1805
- var log6 = createLogger("Memory");
1680
+ var log5 = createLogger("Memory");
1806
1681
  function reorderForEdges(items) {
1807
1682
  if (items.length <= 2) return items;
1808
1683
  const result = new Array(items.length);
@@ -1851,7 +1726,7 @@ var ContextBuilder = class {
1851
1726
  recentTgMessages.filter((m) => m.text && m.text.length > 0).map((m) => m.text)
1852
1727
  );
1853
1728
  const knowledgePromise = includeAgentMemory ? this.hybridSearch.searchKnowledge(query, queryEmbedding, { limit: maxRelevantChunks }).catch((error) => {
1854
- log6.warn({ err: error }, "Knowledge search failed");
1729
+ log5.warn({ err: error }, "Knowledge search failed");
1855
1730
  return [];
1856
1731
  }) : Promise.resolve([]);
1857
1732
  const { afterTimestamp } = parseTemporalIntent(query);
@@ -1860,7 +1735,7 @@ var ContextBuilder = class {
1860
1735
  limit: maxRelevantChunks,
1861
1736
  afterTimestamp
1862
1737
  }).catch((error) => {
1863
- log6.warn({ err: error }, "Feed search failed");
1738
+ log5.warn({ err: error }, "Feed search failed");
1864
1739
  return [];
1865
1740
  }) : Promise.resolve([]);
1866
1741
  const [knowledgeResults, feedResults] = await Promise.all([knowledgePromise, feedPromise]);
@@ -1888,7 +1763,7 @@ var ContextBuilder = class {
1888
1763
  }
1889
1764
  }
1890
1765
  } catch (error) {
1891
- log6.warn({ err: error }, "Global feed search failed");
1766
+ log5.warn({ err: error }, "Global feed search failed");
1892
1767
  }
1893
1768
  }
1894
1769
  if (relevantFeed.length === 0 && recentTgMessages.length > 0) {
@@ -1927,11 +1802,6 @@ function initializeMemory(config) {
1927
1802
  }
1928
1803
 
1929
1804
  export {
1930
- JOURNAL_SCHEMA,
1931
- USED_TRANSACTIONS_SCHEMA,
1932
- openModuleDb,
1933
- createDbWrapper,
1934
- migrateFromMainDb,
1935
1805
  ensureSchema,
1936
1806
  ensureVectorTables,
1937
1807
  getSchemaVersion,