lynkr 7.2.0 → 7.2.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lynkr",
3
- "version": "7.2.0",
3
+ "version": "7.2.1",
4
4
  "description": "Self-hosted Claude Code & Cursor proxy with Databricks,AWS BedRock,Azure adapters, openrouter, Ollama,llamacpp,LM Studio, workspace tooling, and MCP integration.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -1,24 +1,39 @@
1
- const Database = require("better-sqlite3");
1
+ let Database;
2
+ try {
3
+ Database = require("better-sqlite3");
4
+ } catch {
5
+ Database = null;
6
+ }
2
7
  const path = require("path");
3
8
  const fs = require("fs");
4
9
  const logger = require("../logger");
5
10
 
6
11
  class AgentStore {
7
12
  constructor() {
8
- // Use same database location as main app
9
- const dbDir = path.join(process.cwd(), "data");
10
- if (!fs.existsSync(dbDir)) {
11
- fs.mkdirSync(dbDir, { recursive: true });
13
+ if (!Database) {
14
+ this.db = null;
15
+ return;
12
16
  }
13
17
 
14
- const dbPath = path.join(dbDir, "lynkr.db");
15
- this.db = new Database(dbPath, {
16
- verbose: process.env.DEBUG_SQL ? console.log : null,
17
- fileMustExist: false
18
- });
19
-
20
- this.initTables();
21
- this.prepareStatements();
18
+ try {
19
+ // Use same database location as main app
20
+ const dbDir = path.join(process.cwd(), "data");
21
+ if (!fs.existsSync(dbDir)) {
22
+ fs.mkdirSync(dbDir, { recursive: true });
23
+ }
24
+
25
+ const dbPath = path.join(dbDir, "lynkr.db");
26
+ this.db = new Database(dbPath, {
27
+ verbose: process.env.DEBUG_SQL ? console.log : null,
28
+ fileMustExist: false
29
+ });
30
+
31
+ this.initTables();
32
+ this.prepareStatements();
33
+ } catch (err) {
34
+ logger.warn({ err: err.message }, "AgentStore: better-sqlite3 not available");
35
+ this.db = null;
36
+ }
22
37
  }
23
38
 
24
39
  initTables() {
@@ -16,15 +16,21 @@ class BudgetManager {
16
16
  return;
17
17
  }
18
18
 
19
- const dbPath = path.join(process.cwd(), 'data', 'budgets.db');
20
- const dbDir = path.dirname(dbPath);
19
+ try {
20
+ const dbPath = path.join(process.cwd(), 'data', 'budgets.db');
21
+ const dbDir = path.dirname(dbPath);
21
22
 
22
- if (!fs.existsSync(dbDir)) {
23
- fs.mkdirSync(dbDir, { recursive: true });
24
- }
23
+ if (!fs.existsSync(dbDir)) {
24
+ fs.mkdirSync(dbDir, { recursive: true });
25
+ }
25
26
 
26
- this.db = new Database(dbPath);
27
- this.initDatabase();
27
+ this.db = new Database(dbPath);
28
+ this.initDatabase();
29
+ } catch (err) {
30
+ logger.warn({ err: err.message }, "BudgetManager: better-sqlite3 not available");
31
+ this.enabled = false;
32
+ return;
33
+ }
28
34
 
29
35
  logger.info({ dbPath }, 'Budget manager initialized');
30
36
  }
@@ -1,5 +1,10 @@
1
1
  const crypto = require("crypto");
2
- const Database = require("better-sqlite3");
2
+ let Database;
3
+ try {
4
+ Database = require("better-sqlite3");
5
+ } catch {
6
+ Database = null;
7
+ }
3
8
  const path = require("path");
4
9
  const fs = require("fs");
5
10
  const config = require("../config");
@@ -49,9 +54,11 @@ class PromptCache {
49
54
  this.isClosed = false; // Track if database has been closed
50
55
 
51
56
  // Initialize persistent cache database
52
- if (this.enabled) {
57
+ if (this.enabled && Database) {
53
58
  this.initDatabase();
54
59
  this.startPruning();
60
+ } else if (!Database) {
61
+ this.enabled = false;
55
62
  }
56
63
  }
57
64