upfynai-code 3.0.0 → 3.0.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": "upfynai-code",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "Visual AI coding interface for Claude Code, Cursor & Codex. Canvas whiteboard, multi-agent chat, terminal, git, voice assistant. Self-host locally or connect to cli.upfyn.com for remote access.",
5
5
  "type": "module",
6
6
  "main": "server/index.js",
@@ -56,7 +56,6 @@
56
56
  "@anthropic-ai/claude-agent-sdk": "^0.1.71",
57
57
  "@anthropic-ai/sdk": "^0.78.0",
58
58
  "@iarna/toml": "^2.2.5",
59
- "@libsql/client": "^0.14.0",
60
59
  "@modelcontextprotocol/sdk": "^1.26.0",
61
60
  "@openai/codex-sdk": "^0.101.0",
62
61
  "bcryptjs": "^3.0.3",
@@ -70,6 +69,7 @@
70
69
  "gray-matter": "^4.0.3",
71
70
  "js-yaml": "^4.1.0",
72
71
  "jsonwebtoken": "^9.0.2",
72
+ "libsql": "^0.5.22",
73
73
  "mime-types": "^3.0.1",
74
74
  "multer": "^2.0.2",
75
75
  "ws": "^8.14.2",
@@ -1,9 +1,49 @@
1
+ // ─── Database Client Resolution ──────────────────────────────────────────────
2
+ // Cloud (Railway): uses @libsql/client for Turso remote databases
3
+ // Local (npm install): uses libsql (native SQLite binding) with async adapter
4
+ // This avoids shipping deprecated transitive deps (node-domexception) to npm users
5
+
1
6
  let createClient;
7
+
8
+ // 1. Try @libsql/client (cloud — installed on Railway via nixpacks)
2
9
  try {
3
10
  createClient = (await import('@libsql/client')).createClient;
4
- } catch (e) {
5
- console.warn('[DB] @libsql/client not available cloud database features disabled.', e?.message || '');
11
+ } catch {
12
+ // 2. Fallback: use libsql native binding with async adapter (local installs)
13
+ try {
14
+ const DatabaseMod = await import('libsql');
15
+ const Database = DatabaseMod.default || DatabaseMod;
16
+ createClient = function createLocalClient({ url }) {
17
+ const dbPath = url.replace(/^file:/, '');
18
+ const sqliteDb = new Database(dbPath);
19
+ sqliteDb.pragma('journal_mode = WAL');
20
+ return {
21
+ execute: async (query) => {
22
+ const sql = typeof query === 'string' ? query : query.sql;
23
+ const args = typeof query === 'string' ? [] : (query.args || []);
24
+ const stmt = sqliteDb.prepare(sql);
25
+ if (sql.trim().match(/^(SELECT|PRAGMA|EXPLAIN)/i)) {
26
+ const rows = args.length ? stmt.all(...args) : stmt.all();
27
+ return { rows, columns: rows.length > 0 ? Object.keys(rows[0]) : [] };
28
+ }
29
+ const info = args.length ? stmt.run(...args) : stmt.run();
30
+ return { rows: [], columns: [], rowsAffected: info.changes, lastInsertRowid: info.lastInsertRowid };
31
+ },
32
+ batch: async (queries) => {
33
+ const results = [];
34
+ for (const q of queries) {
35
+ results.push(await createClient._lastInstance.execute(q));
36
+ }
37
+ return results;
38
+ },
39
+ close: () => sqliteDb.close(),
40
+ };
41
+ };
42
+ } catch {
43
+ // Neither available
44
+ }
6
45
  }
46
+
7
47
  import path from 'path';
8
48
  import fs from 'fs';
9
49
  import crypto from 'crypto';
@@ -50,7 +90,7 @@ function resolveDbConfig() {
50
90
  function getDb() {
51
91
  if (!_db) {
52
92
  if (!createClient) {
53
- throw new Error('[DB] @libsql/client is not installed. Run: npm install @libsql/client');
93
+ throw new Error('[DB] No database driver available. Install libsql or @libsql/client.');
54
94
  }
55
95
  resolveDbConfig();
56
96
  _db = createClient({ url: _dbUrl, ...(_dbAuthToken ? { authToken: _dbAuthToken } : {}) });