@geekbeer/minion 3.5.30 → 3.5.31
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/core/db.js +60 -6
- package/linux/minion-cli.sh +0 -1
- package/package.json +2 -2
package/core/db.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* SQLite Database Module
|
|
3
3
|
* Provides a singleton SQLite database connection for all minion stores.
|
|
4
4
|
* Uses better-sqlite3 (synchronous API) with WAL mode for performance.
|
|
5
|
+
* Falls back to Node.js built-in node:sqlite when better-sqlite3 is unavailable
|
|
6
|
+
* (e.g., no prebuilt binaries for the current Node.js version on Windows).
|
|
5
7
|
*
|
|
6
8
|
* Database file: $DATA_DIR/minion.db
|
|
7
9
|
*
|
|
@@ -33,6 +35,63 @@ function resolveDbPath() {
|
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Open a database connection using better-sqlite3 or node:sqlite fallback.
|
|
40
|
+
* @param {string} dbPath
|
|
41
|
+
* @returns {import('better-sqlite3').Database}
|
|
42
|
+
*/
|
|
43
|
+
function openDatabase(dbPath) {
|
|
44
|
+
// Try better-sqlite3 first (fastest, has prebuilt binaries for most platforms)
|
|
45
|
+
try {
|
|
46
|
+
const Database = require('better-sqlite3')
|
|
47
|
+
const db = new Database(dbPath)
|
|
48
|
+
db.pragma('journal_mode = WAL')
|
|
49
|
+
db.pragma('foreign_keys = ON')
|
|
50
|
+
console.log('[DB] Using better-sqlite3')
|
|
51
|
+
return db
|
|
52
|
+
} catch (e) {
|
|
53
|
+
console.log(`[DB] better-sqlite3 unavailable (${e.message}), trying node:sqlite...`)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Fallback to Node.js built-in sqlite (available in Node 22.5.0+)
|
|
57
|
+
try {
|
|
58
|
+
const { DatabaseSync } = require('node:sqlite')
|
|
59
|
+
const db = new DatabaseSync(dbPath)
|
|
60
|
+
db.exec('PRAGMA journal_mode = WAL')
|
|
61
|
+
db.exec('PRAGMA foreign_keys = ON')
|
|
62
|
+
|
|
63
|
+
// Polyfill db.pragma() for compatibility with better-sqlite3 API
|
|
64
|
+
db.pragma = function (str) {
|
|
65
|
+
const stmt = db.prepare(`PRAGMA ${str}`)
|
|
66
|
+
return stmt.get()
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Polyfill db.transaction() for compatibility with better-sqlite3 API
|
|
70
|
+
db.transaction = function (fn) {
|
|
71
|
+
return function (...args) {
|
|
72
|
+
db.exec('BEGIN')
|
|
73
|
+
try {
|
|
74
|
+
const result = fn(...args)
|
|
75
|
+
db.exec('COMMIT')
|
|
76
|
+
return result
|
|
77
|
+
} catch (e) {
|
|
78
|
+
db.exec('ROLLBACK')
|
|
79
|
+
throw e
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
console.log('[DB] Using node:sqlite (built-in)')
|
|
85
|
+
return db
|
|
86
|
+
} catch (e) {
|
|
87
|
+
throw new Error(
|
|
88
|
+
`[DB] No SQLite driver available. Install better-sqlite3 or use Node.js 22.5.0+ for built-in sqlite support. ` +
|
|
89
|
+
`better-sqlite3 error: check that Python and build tools are installed, or use Node.js 22 LTS which has prebuilt binaries. ` +
|
|
90
|
+
`node:sqlite error: ${e.message}`
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
36
95
|
/**
|
|
37
96
|
* Get the singleton database connection.
|
|
38
97
|
* Initializes the database and schema on first call.
|
|
@@ -44,12 +103,7 @@ function getDb() {
|
|
|
44
103
|
const dbPath = resolveDbPath()
|
|
45
104
|
fs.mkdirSync(path.dirname(dbPath), { recursive: true })
|
|
46
105
|
|
|
47
|
-
|
|
48
|
-
_db = new Database(dbPath)
|
|
49
|
-
|
|
50
|
-
// Performance & integrity settings
|
|
51
|
-
_db.pragma('journal_mode = WAL')
|
|
52
|
-
_db.pragma('foreign_keys = ON')
|
|
106
|
+
_db = openDatabase(dbPath)
|
|
53
107
|
|
|
54
108
|
initSchema(_db)
|
|
55
109
|
migrateSchema(_db)
|
package/linux/minion-cli.sh
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geekbeer/minion",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.31",
|
|
4
4
|
"description": "AI Agent runtime for Minion - manages status and skill deployment on VPS",
|
|
5
5
|
"main": "linux/server.js",
|
|
6
6
|
"bin": {
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
"postinstall": "node postinstall.js"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"better-sqlite3": "^11.0.0",
|
|
31
30
|
"croner": "^9.0.0",
|
|
32
31
|
"fastify": "^5.2.2",
|
|
33
32
|
"ws": "^8.0.0"
|
|
34
33
|
},
|
|
35
34
|
"optionalDependencies": {
|
|
35
|
+
"better-sqlite3": "^11.0.0",
|
|
36
36
|
"node-pty": "^1.0.0"
|
|
37
37
|
},
|
|
38
38
|
"engines": {
|