claude-flow 2.7.44 → 2.7.46

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/bin/claude-flow CHANGED
@@ -2,7 +2,7 @@
2
2
  # Claude-Flow Smart Dispatcher - Detects and uses the best available runtime
3
3
  # Enhanced with NPX cache error handling and retry logic
4
4
 
5
- VERSION="2.7.44"
5
+ VERSION="2.7.46"
6
6
 
7
7
  # Determine the correct path based on how the script is invoked
8
8
  if [ -L "$0" ]; then
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/cli/validation-helper.js"],"sourcesContent":["/**\n * CLI Parameter Validation Helper\n * Provides standardized error messages for invalid parameters\n */\n\nimport { HelpFormatter } from './help-formatter.js';\n\nexport class ValidationHelper {\n /**\n * Validate enum parameter\n */\n static validateEnum(value, paramName, validOptions, commandPath) {\n if (!validOptions.includes(value)) {\n console.error(\n HelpFormatter.formatValidationError(value, paramName, validOptions, commandPath),\n );\n process.exit(1);\n }\n }\n\n /**\n * Validate numeric parameter\n */\n static validateNumber(value, paramName, min, max, commandPath) {\n const num = parseInt(value, 10);\n\n if (isNaN(num)) {\n console.error(\n HelpFormatter.formatError(\n `'${value}' is not a valid number for ${paramName}.`,\n commandPath || 'claude-flow',\n ),\n );\n process.exit(1);\n }\n\n if (min !== undefined && num < min) {\n console.error(\n HelpFormatter.formatError(\n `${paramName} must be at least ${min}. Got: ${num}`,\n commandPath || 'claude-flow',\n ),\n );\n process.exit(1);\n }\n\n if (max !== undefined && num > max) {\n console.error(\n HelpFormatter.formatError(\n `${paramName} must be at most ${max}. Got: ${num}`,\n commandPath || 'claude-flow',\n ),\n );\n process.exit(1);\n }\n\n return num;\n }\n\n /**\n * Validate required parameter\n */\n static validateRequired(value, paramName, commandPath) {\n if (!value || (typeof value === 'string' && value.trim() === '')) {\n console.error(\n HelpFormatter.formatError(\n `Missing required parameter: ${paramName}`,\n commandPath || 'claude-flow',\n ),\n );\n process.exit(1);\n }\n }\n\n /**\n * Validate file path exists\n */\n static async validateFilePath(path, paramName, commandPath) {\n try {\n const fs = await import('fs/promises');\n await fs.access(path);\n } catch (error) {\n console.error(\n HelpFormatter.formatError(\n `File not found for ${paramName}: ${path}`,\n commandPath || 'claude-flow',\n ),\n );\n process.exit(1);\n }\n }\n\n /**\n * Validate boolean flag\n */\n static validateBoolean(value, paramName, commandPath) {\n const lowerValue = value.toLowerCase();\n if (lowerValue === 'true' || lowerValue === '1' || lowerValue === 'yes') {\n return true;\n }\n if (lowerValue === 'false' || lowerValue === '0' || lowerValue === 'no') {\n return false;\n }\n\n console.error(\n HelpFormatter.formatError(\n `'${value}' is not a valid boolean for ${paramName}. Use: true, false, yes, no, 1, or 0.`,\n commandPath || 'claude-flow',\n ),\n );\n process.exit(1);\n }\n}\n"],"names":["HelpFormatter","ValidationHelper","validateEnum","value","paramName","validOptions","commandPath","includes","console","error","formatValidationError","process","exit","validateNumber","min","max","num","parseInt","isNaN","formatError","undefined","validateRequired","trim","validateFilePath","path","fs","access","validateBoolean","lowerValue","toLowerCase"],"mappings":"AAKA,SAASA,aAAa,QAAQ,sBAAsB;AAEpD,OAAO,MAAMC;IAIX,OAAOC,aAAaC,KAAK,EAAEC,SAAS,EAAEC,YAAY,EAAEC,WAAW,EAAE;QAC/D,IAAI,CAACD,aAAaE,QAAQ,CAACJ,QAAQ;YACjCK,QAAQC,KAAK,CACXT,cAAcU,qBAAqB,CAACP,OAAOC,WAAWC,cAAcC;YAEtEK,QAAQC,IAAI,CAAC;QACf;IACF;IAKA,OAAOC,eAAeV,KAAK,EAAEC,SAAS,EAAEU,GAAG,EAAEC,GAAG,EAAET,WAAW,EAAE;QAC7D,MAAMU,MAAMC,SAASd,OAAO;QAE5B,IAAIe,MAAMF,MAAM;YACdR,QAAQC,KAAK,CACXT,cAAcmB,WAAW,CACvB,CAAC,CAAC,EAAEhB,MAAM,4BAA4B,EAAEC,UAAU,CAAC,CAAC,EACpDE,eAAe;YAGnBK,QAAQC,IAAI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,KAAK,CACXT,cAAcmB,WAAW,CACvB,CAAC,CAAC,EAAEhB,MAAM,6BAA6B,EAAEC,UAAU,qCAAqC,CAAC,EACzFE,eAAe;QAGnBK,QAAQC,IAAI,CAAC;IACf;AACF"}MsB,aAAazB,MAAM0B,WAAW;QACpC,IAAID,eAAe,UAAUA,eAAe,OAAOA,eAAe,OAAO;YACvE,OAAO;QACT;QACA,IAAIA,eAAe,WAAWA,eAAe,OAAOA,eAAe,MAAM;YACvE,OAAO;QACT;QAEApB,QAAQC,KAAK,CACXT,cAAcmB,WAAW,CACvB,CAAC,CAAC,EAAEhB,MAAM,6BAA6B,EAAEC,UAAU,qCAAqC,CAAC,EACzFE,eAAe;QAGnBK,QAAQC,IAAI,CAAC;IACf;AACF"}
1
+ {"version":3,"sources":["../../../src/cli/validation-helper.ts"],"sourcesContent":["/**\n * CLI Parameter Validation Helper\n * Provides standardized error messages for invalid parameters\n */\n\nimport { HelpFormatter } from './help-formatter.js';\n\nexport class ValidationHelper {\n /**\n * Validate enum parameter\n */\n static validateEnum(\n value: string,\n paramName: string,\n validOptions: string[],\n commandPath: string,\n ): void {\n if (!validOptions.includes(value)) {\n console.error(\n HelpFormatter.formatValidationError(value, paramName, validOptions, commandPath),\n );\n process.exit(1);\n }\n }\n\n /**\n * Validate numeric parameter\n */\n static validateNumber(\n value: string,\n paramName: string,\n min?: number,\n max?: number,\n commandPath?: string,\n ): number {\n const num = parseInt(value, 10);\n\n if (isNaN(num)) {\n console.error(\n HelpFormatter.formatError(\n `'${value}' is not a valid number for ${paramName}.`,\n commandPath || 'claude-flow',\n ),\n );\n process.exit(1);\n }\n\n if (min !== undefined && num < min) {\n console.error(\n HelpFormatter.formatError(\n `${paramName} must be at least ${min}. Got: ${num}`,\n commandPath || 'claude-flow',\n ),\n );\n process.exit(1);\n }\n\n if (max !== undefined && num > max) {\n console.error(\n HelpFormatter.formatError(\n `${paramName} must be at most ${max}. Got: ${num}`,\n commandPath || 'claude-flow',\n ),\n );\n process.exit(1);\n }\n\n return num;\n }\n\n /**\n * Validate required parameter\n */\n static validateRequired(value: any, paramName: string, commandPath?: string): void {\n if (!value || (typeof value === 'string' && value.trim() === '')) {\n console.error(\n HelpFormatter.formatError(\n `Missing required parameter: ${paramName}`,\n commandPath || 'claude-flow',\n ),\n );\n process.exit(1);\n }\n }\n\n /**\n * Validate file path exists\n */\n static async validateFilePath(\n path: string,\n paramName: string,\n commandPath?: string,\n ): Promise<void> {\n try {\n const fs = await import('fs/promises');\n await fs.access(path);\n } catch (error) {\n console.error(\n HelpFormatter.formatError(\n `File not found for ${paramName}: ${path}`,\n commandPath || 'claude-flow',\n ),\n );\n process.exit(1);\n }\n }\n\n /**\n * Validate boolean flag\n */\n static validateBoolean(value: string, paramName: string, commandPath?: string): boolean {\n const lowerValue = value.toLowerCase();\n if (lowerValue === 'true' || lowerValue === '1' || lowerValue === 'yes') {\n return true;\n }\n if (lowerValue === 'false' || lowerValue === '0' || lowerValue === 'no') {\n return false;\n }\n\n console.error(\n HelpFormatter.formatError(\n `'${value}' is not a valid boolean for ${paramName}. Use: true, false, yes, no, 1, or 0.`,\n commandPath || 'claude-flow',\n ),\n );\n process.exit(1);\n }\n}\n"],"names":["HelpFormatter","ValidationHelper","validateEnum","value","paramName","validOptions","commandPath","includes","console","error","formatValidationError","process","exit","validateNumber","min","max","num","parseInt","isNaN","formatError","undefined","validateRequired","trim","validateFilePath","path","fs","access","validateBoolean","lowerValue","toLowerCase"],"mappings":"AAKA,SAASA,aAAa,QAAQ,sBAAsB;AAEpD,OAAO,MAAMC;IAIX,OAAOC,aACLC,KAAa,EACbC,SAAiB,EACjBC,YAAsB,EACtBC,WAAmB,EACb;QACN,IAAI,CAACD,aAAaE,QAAQ,CAACJ,QAAQ;YACjCK,QAAQC,KAAK,CACXT,cAAcU,qBAAqB,CAACP,OAAOC,WAAWC,cAAcC;YAEtEK,QAAQC,IAAI,CAAC;QACf;IACF;IAKA,OAAOC,eACLV,KAAa,EACbC,SAAiB,EAC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AAOe,gBAAgBxB,KAAa,EAAEC,SAAiB,EAAEE,WAAoB,EAAW;QACtF,MAAMsB,aAAazB,MAAM0B,WAAW;QACpC,IAAID,eAAe,UAAUA,eAAe,OAAOA,eAAe,OAAO;YACvE,OAAO;QACT;QACA,IAAIA,eAAe,WAAWA,eAAe,OAAOA,eAAe,MAAM;YACvE,OAAO;QACT;QAEApB,QAAQC,KAAK,CACXT,cAAcmB,WAAW,CACvB,CAAC,CAAC,EAAEhB,MAAM,6BAA6B,EAAEC,UAAU,qCAAqC,CAAC,EACzFE,eAAe;QAGnBK,QAAQC,IAAI,CAAC;IACf;AACF"}
@@ -23,4 +23,4 @@ export function displayVersion() {
23
23
  console.log(getVersionString());
24
24
  }
25
25
 
26
- //# sourceMappingURL=version.js.mapp
26
+ //# sourceMappingURL=version.js.map
@@ -1,4 +1,5 @@
1
1
  import { createRequire } from 'module';
2
+ import { execSync } from 'child_process';
2
3
  import path from 'path';
3
4
  import { fileURLToPath } from 'url';
4
5
  const __filename = fileURLToPath(import.meta.url);
@@ -6,6 +7,31 @@ const __dirname = path.dirname(__filename);
6
7
  let Database = null;
7
8
  let sqliteAvailable = false;
8
9
  let loadError = null;
10
+ let rebuildAttempted = false;
11
+ function tryRebuildBetterSqlite3() {
12
+ if (rebuildAttempted) return false;
13
+ rebuildAttempted = true;
14
+ try {
15
+ const require = createRequire(import.meta.url);
16
+ const betterSqlite3Path = path.dirname(require.resolve('better-sqlite3/package.json'));
17
+ console.warn(`\nšŸ”§ Attempting to rebuild better-sqlite3 for Node.js ${process.version}...`);
18
+ execSync('npm rebuild', {
19
+ cwd: betterSqlite3Path,
20
+ stdio: [
21
+ 'pipe',
22
+ 'pipe',
23
+ 'pipe'
24
+ ],
25
+ timeout: 120000
26
+ });
27
+ console.warn(`āœ… Rebuild successful! Retrying SQLite load...\n`);
28
+ return true;
29
+ } catch (err) {
30
+ console.warn(`āš ļø Auto-rebuild failed: ${err.message}`);
31
+ console.warn(` You may need build tools installed (python, make, g++)\n`);
32
+ return false;
33
+ }
34
+ }
9
35
  async function tryLoadSQLite() {
10
36
  try {
11
37
  const require = createRequire(import.meta.url);
@@ -22,6 +48,19 @@ async function tryLoadSQLite() {
22
48
  loadError = importErr;
23
49
  const isVersionMismatch = requireErr.message?.includes('NODE_MODULE_VERSION') || importErr.message?.includes('NODE_MODULE_VERSION') || requireErr.message?.includes('was compiled against a different Node.js version') || importErr.message?.includes('was compiled against a different Node.js version');
24
50
  if (isVersionMismatch) {
51
+ if (!rebuildAttempted && tryRebuildBetterSqlite3()) {
52
+ try {
53
+ const require = createRequire(import.meta.url);
54
+ const modulePath = require.resolve('better-sqlite3');
55
+ delete require.cache[modulePath];
56
+ Database = require('better-sqlite3');
57
+ sqliteAvailable = true;
58
+ loadError = null;
59
+ return true;
60
+ } catch (retryErr) {
61
+ loadError = retryErr;
62
+ }
63
+ }
25
64
  const errorMsg = requireErr.message || importErr.message || '';
26
65
  const compiledMatch = errorMsg.match(/NODE_MODULE_VERSION (\d+)/);
27
66
  const requiredMatch = errorMsg.match(/requires\s+NODE_MODULE_VERSION (\d+)/);
@@ -45,18 +84,16 @@ async function tryLoadSQLite() {
45
84
  ā•‘ ā•‘
46
85
  ā•‘ The better-sqlite3 module was compiled for a different Node.js version. ā•‘${versionInfo}
47
86
  ā•‘ ā•‘
87
+ ā•‘ Auto-rebuild was attempted but SQLite is still unavailable. ā•‘
48
88
  ā•‘ Claude Flow will continue with JSON fallback storage (still works fine). ā•‘
49
89
  ā•‘ ā•‘
50
- ā•‘ To fix this and use SQLite: ā•‘
51
- ā•‘ ā•‘
52
- ā•‘ Option 1 - Rebuild the module: ā•‘
53
- ā•‘ > npm rebuild better-sqlite3 ā•‘
90
+ ā•‘ To manually fix this and use SQLite: ā•‘
54
91
  ā•‘ ā•‘
55
- ā•‘ Option 2 - Clear npx cache (if using npx): ā•‘
56
- ā•‘ > rm -rf ~/.npm/_npx/ && npx claude-flow@alpha ... ā•‘
92
+ ā•‘ Option 1 - Global install (recommended): ā•‘
93
+ ā•‘ > npm install -g claude-flow@alpha ā•‘
57
94
  ā•‘ ā•‘
58
- ā•‘ Option 3 - Reinstall dependencies: ā•‘
59
- ā•‘ > rm -rf node_modules && npm install ā•‘
95
+ ā•‘ Option 2 - Clear npx cache: ā•‘
96
+ ā•‘ > rm -rf ~/.npm/_npx/ && npx claude-flow@alpha ... ā•‘
60
97
  ā•‘ ā•‘
61
98
  ā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•
62
99
  `);
@@ -113,7 +150,27 @@ export async function createDatabase(dbPath) {
113
150
  try {
114
151
  return new DB(dbPath);
115
152
  } catch (err) {
116
- if (err.message.includes('EPERM') || err.message.includes('access denied')) {
153
+ const isVersionMismatch = err.message?.includes('NODE_MODULE_VERSION') || err.message?.includes('was compiled against a different Node.js version') || err.code === 'ERR_DLOPEN_FAILED';
154
+ if (isVersionMismatch && !rebuildAttempted) {
155
+ if (tryRebuildBetterSqlite3()) {
156
+ try {
157
+ const require = createRequire(import.meta.url);
158
+ const modulePath = require.resolve('better-sqlite3');
159
+ delete require.cache[modulePath];
160
+ Object.keys(require.cache).forEach((key)=>{
161
+ if (key.includes('better_sqlite3.node') || key.includes('better-sqlite3')) {
162
+ delete require.cache[key];
163
+ }
164
+ });
165
+ const NewDB = require('better-sqlite3');
166
+ Database = NewDB;
167
+ return new NewDB(dbPath);
168
+ } catch (retryErr) {
169
+ throw err;
170
+ }
171
+ }
172
+ }
173
+ if (err.message?.includes('EPERM') || err.message?.includes('access denied')) {
117
174
  throw new Error(`Cannot create database at ${dbPath}. Permission denied. Try using a different directory or running with administrator privileges.`);
118
175
  }
119
176
  throw err;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/memory/sqlite-wrapper.js"],"sourcesContent":["/**\n * SQLite Wrapper with Windows Fallback Support\n * Provides graceful fallback when better-sqlite3 fails to load\n */\n\nimport { createRequire } from 'module';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nlet Database = null;\nlet sqliteAvailable = false;\nlet loadError = null;\n\n/**\n * Try to load better-sqlite3 with comprehensive error handling\n */\nasync function tryLoadSQLite() {\n try {\n // Try CommonJS require first (more reliable in Node.js)\n const require = createRequire(import.meta.url);\n Database = require('better-sqlite3');\n sqliteAvailable = true;\n return true;\n } catch (requireErr) {\n // Fallback to ES module import\n try {\n const module = await import('better-sqlite3');\n Database = module.default;\n sqliteAvailable = true;\n return true;\n } catch (importErr) {\n loadError = importErr;\n\n // Check for NODE_MODULE_VERSION mismatch (different Node.js ABI)\n const isVersionMismatch =\n requireErr.message?.includes('NODE_MODULE_VERSION') ||\n importErr.message?.includes('NODE_MODULE_VERSION') ||\n requireErr.message?.includes('was compiled against a different Node.js version') ||\n importErr.message?.includes('was compiled against a different Node.js version');\n\n if (isVersionMismatch) {\n // Extract version info for helpful message\n const errorMsg = requireErr.message || importErr.message || '';\n const compiledMatch = errorMsg.match(/NODE_MODULE_VERSION (\\d+)/);\n const requiredMatch = errorMsg.match(/requires\\s+NODE_MODULE_VERSION (\\d+)/);\n\n const nodeVersionMap = {\n '108': '18.x', '115': '20.x', '120': '21.x', '127': '22.x', '131': '23.x'\n };\n\n let versionInfo = '';\n if (compiledMatch && requiredMatch) {\n const compiled = nodeVersionMap[compiledMatch[1]] || `ABI ${compiledMatch[1]}`;\n const required = nodeVersionMap[requiredMatch[1]] || `ABI ${requiredMatch[1]}`;\n versionInfo = `\\nā•‘ Module compiled for Node.js ${compiled}, running Node.js ${required}`.padEnd(79) + 'ā•‘';\n }\n\n console.warn(`\n╔══════════════════════════════════════════════════════════════════════════════╗\nā•‘ Native Module Version Mismatch (NODE_MODULE_VERSION) ā•‘\n╠══════════════════════════════════════════════════════════════════════════════╣\nā•‘ ā•‘\nā•‘ The better-sqlite3 module was compiled for a different Node.js version. ā•‘${versionInfo}\nā•‘ ā•‘\nā•‘ Claude Flow will continue with JSON fallback storage (still works fine). ā•‘\nā•‘ ā•‘\nā•‘ To fix this and use SQLite: ā•‘\nā•‘ ā•‘\nā•‘ Option 1 - Rebuild the module: ā•‘\nā•‘ > npm rebuild better-sqlite3 ā•‘\nā•‘ ā•‘\nā•‘ Option 2 - Clear npx cache (if using npx): ā•‘\nā•‘ > rm -rf ~/.npm/_npx/ && npx claude-flow@alpha ... ā•‘\nā•‘ ā•‘\nā•‘ Option 3 - Reinstall dependencies: ā•‘\nā•‘ > rm -rf node_modules && npm install ā•‘\nā•‘ ā•‘\nā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•\n`);\n return false;\n }\n\n // Check for other Windows/installation errors\n if (requireErr.message?.includes('Could not locate the bindings file') ||\n requireErr.message?.includes('The specified module could not be found') ||\n requireErr.code === 'MODULE_NOT_FOUND') {\n\n console.warn(`\n╔══════════════════════════════════════════════════════════════════════════════╗\nā•‘ SQLite Native Module Installation Issue ā•‘\n╠══════════════════════════════════════════════════════════════════════════════╣\nā•‘ ā•‘\nā•‘ The native SQLite module failed to load. This is common on Windows when ā•‘\nā•‘ using 'npx' or when node-gyp build tools are not available. ā•‘\nā•‘ ā•‘\nā•‘ Claude Flow will continue with JSON fallback storage (still works fine). ā•‘\nā•‘ ā•‘\nā•‘ To enable SQLite storage: ā•‘\nā•‘ ā•‘\nā•‘ Option 1 - Install Build Tools (Windows): ā•‘\nā•‘ > npm install --global windows-build-tools ā•‘\nā•‘ > npm install claude-flow@alpha ā•‘\nā•‘ ā•‘\nā•‘ Option 2 - Use WSL (Windows Subsystem for Linux): ā•‘\nā•‘ Install WSL and run Claude Flow inside a Linux environment ā•‘\nā•‘ ā•‘\nā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•\n`);\n }\n \n return false;\n }\n }\n}\n\n/**\n * Check if SQLite is available\n */\nexport async function isSQLiteAvailable() {\n if (sqliteAvailable !== null) {\n return sqliteAvailable;\n }\n \n await tryLoadSQLite();\n return sqliteAvailable;\n}\n\n/**\n * Get SQLite Database constructor or null\n */\nexport async function getSQLiteDatabase() {\n if (!sqliteAvailable && loadError === null) {\n await tryLoadSQLite();\n }\n \n return Database;\n}\n\n/**\n * Get the load error if any\n */\nexport function getLoadError() {\n return loadError;\n}\n\n/**\n * Create a SQLite database instance with fallback\n */\nexport async function createDatabase(dbPath) {\n const DB = await getSQLiteDatabase();\n \n if (!DB) {\n throw new Error('SQLite is not available. Use fallback storage instead.');\n }\n \n try {\n return new DB(dbPath);\n } catch (err) {\n // Additional Windows-specific error handling\n if (err.message.includes('EPERM') || err.message.includes('access denied')) {\n throw new Error(`Cannot create database at ${dbPath}. Permission denied. Try using a different directory or running with administrator privileges.`);\n }\n throw err;\n }\n}\n\n/**\n * Check if running on Windows\n */\nexport function isWindows() {\n return process.platform === 'win32';\n}\n\n/**\n * Get platform-specific storage recommendations\n */\nexport function getStorageRecommendations() {\n if (isWindows()) {\n return {\n recommended: 'in-memory',\n reason: 'Windows native module compatibility',\n alternatives: [\n 'Install Windows build tools for SQLite support',\n 'Use WSL (Windows Subsystem for Linux)',\n 'Use Docker container with Linux'\n ]\n };\n }\n \n return {\n recommended: 'sqlite',\n reason: 'Best performance and persistence',\n alternatives: ['in-memory for testing']\n };\n}\n\n// Pre-load SQLite on module import\ntryLoadSQLite().catch(() => {\n // Silently handle initial load failure\n});\n\nexport default {\n isSQLiteAvailable,\n getSQLiteDatabase,\n getLoadError,\n createDatabase,\n isWindows,\n getStorageRecommendations\n};"],"names":["createRequire","path","fileURLToPath","__filename","url","__dirname","dirname","Database","sqliteAvailable","loadError","tryLoadSQLite","require","requireErr","module","default","importErr","isVersionMismatch","message","includes","errorMsg","compiledMatch","match","requiredMatch","nodeVersionMap","versionInfo","compiled","required","padEnd","console","warn","code","isSQLiteAvailable","getSQLiteDatabase","getLoadError","createDatabase","dbPath","DB","Error","err","isWindows","process","platform","getStorageRecommendations","recommended","reason","alternatives","catch"],"mappings":"AAKA,SAASA,aAAa,QAAQ,SAAS;AACvC,OAAOC,UAAU,OAAO;AACxB,SAASC,aAAa,QAAQ,MAAM;AAEpC,MAAMC,aAAaD,cAAc,YAAYE,GAAG;AAChD,MAAMC,YAAYJ,KAAKK,OAAO,CAACH;AAE/B,IAAII,WAAW;AACf,IAAIC,kBAAkB;AACtB,IAAIC,YAAY;AAKhB,eAAeC;IACb,IAAI;QAEF,MAAMC,UAAUX,cAAc,YAAYI,GAAG;QAC7CG,WAAWI,QAAQ;QACnBH,kBAAkB;QAClB,OAAO;IACT,EAAE,OAAOI,YAAY;QAEnB,IAAI;YACF,MAAMC,SAAS,MAAM,MAAM,CAAC;YAC5BN,WAAWM,OAAOC,OAAO;YACzBN,kBAAkB;YAClB,OAAO;QACT,EAAE,OAAOO,WAAW;YAClBN,YAAYM;YAGZ,MAAMC,oBACJJ,WAAWK,OAAO,EAAEC,SAA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1C,MAAMC;IACR;IAEA,OAAOH;AACT;AAKA,OAAO,SAAS0B;IACd,OAAOxB;AACT;AAKA,OAAO,eAAeyB,eAAeC,MAAM;IACzC,MAAMC,KAAK,MAAMJ;IAEjB,IAAI,CAACI,IAAI;QACP,MAAM,IAAIC,MAAM;IAClB;IAEA,IAAI;QACF,OAAO,IAAID,GAAGD;IAChB,EAAE,OAAOG,KAAK;QAEZ,IAAIA,IAAIrB,OAAO,CAACC,QAAQ,CAAC,YAAYoB,IAAIrB,OAAO,CAACC,QAAQ,CAAC,kBAAkB;YAC1E,MAAM,IAAImB,MAAM,CAAC,0BAA0B,EAAEF,OAAO,8FAA8F,CAAC;QACrJ;QACA,MAAMG;IACR;AACF;AAKA,OAAO,SAASC;IACd,OAAOC,QAAQC,QAAQ,KAAK;AAC9B;AAKA,OAAO,SAASC;IACd,IAAIH,aAAa;QACf,OAAO;YACLI,aAAa;YACbC,QAAQ;YACRC,cAAc;gBACZ;gBACA;gBACA;aACD;QACH;IACF;IAEA,OAAO;QACLF,aAAa;QACbC,QAAQ;QACRC,cAAc;YAAC;SAAwB;IACzC;AACF;AAGAnC,gBAAgBoC,KAAK,CAAC,KAEtB;AAEA,eAAe;IACbf;IACAC;IACAC;IACAC;IACAK;IACAG;AACF,EAAE"}
1
+ {"version":3,"sources":["../../../src/memory/sqlite-wrapper.js"],"sourcesContent":["/**\n * SQLite Wrapper with Windows Fallback Support\n * Provides graceful fallback when better-sqlite3 fails to load\n * Includes auto-rebuild for NODE_MODULE_VERSION mismatches\n */\n\nimport { createRequire } from 'module';\nimport { execSync } from 'child_process';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nlet Database = null;\nlet sqliteAvailable = false;\nlet loadError = null;\nlet rebuildAttempted = false;\n\n/**\n * Attempt to rebuild better-sqlite3 for the current Node.js version\n */\nfunction tryRebuildBetterSqlite3() {\n if (rebuildAttempted) return false;\n rebuildAttempted = true;\n\n try {\n // Find the better-sqlite3 module path\n const require = createRequire(import.meta.url);\n const betterSqlite3Path = path.dirname(require.resolve('better-sqlite3/package.json'));\n\n console.warn(`\\nšŸ”§ Attempting to rebuild better-sqlite3 for Node.js ${process.version}...`);\n\n // Run npm rebuild in the better-sqlite3 directory\n execSync('npm rebuild', {\n cwd: betterSqlite3Path,\n stdio: ['pipe', 'pipe', 'pipe'],\n timeout: 120000 // 2 minute timeout\n });\n\n console.warn(`āœ… Rebuild successful! Retrying SQLite load...\\n`);\n return true;\n } catch (err) {\n console.warn(`āš ļø Auto-rebuild failed: ${err.message}`);\n console.warn(` You may need build tools installed (python, make, g++)\\n`);\n return false;\n }\n}\n\n/**\n * Try to load better-sqlite3 with comprehensive error handling\n */\nasync function tryLoadSQLite() {\n try {\n // Try CommonJS require first (more reliable in Node.js)\n const require = createRequire(import.meta.url);\n Database = require('better-sqlite3');\n sqliteAvailable = true;\n return true;\n } catch (requireErr) {\n // Fallback to ES module import\n try {\n const module = await import('better-sqlite3');\n Database = module.default;\n sqliteAvailable = true;\n return true;\n } catch (importErr) {\n loadError = importErr;\n\n // Check for NODE_MODULE_VERSION mismatch (different Node.js ABI)\n const isVersionMismatch =\n requireErr.message?.includes('NODE_MODULE_VERSION') ||\n importErr.message?.includes('NODE_MODULE_VERSION') ||\n requireErr.message?.includes('was compiled against a different Node.js version') ||\n importErr.message?.includes('was compiled against a different Node.js version');\n\n if (isVersionMismatch) {\n // Try auto-rebuild first\n if (!rebuildAttempted && tryRebuildBetterSqlite3()) {\n // Rebuild succeeded, try loading again\n try {\n const require = createRequire(import.meta.url);\n // Clear the require cache to pick up rebuilt module\n const modulePath = require.resolve('better-sqlite3');\n delete require.cache[modulePath];\n Database = require('better-sqlite3');\n sqliteAvailable = true;\n loadError = null;\n return true;\n } catch (retryErr) {\n // Rebuild succeeded but load still failed\n loadError = retryErr;\n }\n }\n\n // Extract version info for helpful message\n const errorMsg = requireErr.message || importErr.message || '';\n const compiledMatch = errorMsg.match(/NODE_MODULE_VERSION (\\d+)/);\n const requiredMatch = errorMsg.match(/requires\\s+NODE_MODULE_VERSION (\\d+)/);\n\n const nodeVersionMap = {\n '108': '18.x', '115': '20.x', '120': '21.x', '127': '22.x', '131': '23.x'\n };\n\n let versionInfo = '';\n if (compiledMatch && requiredMatch) {\n const compiled = nodeVersionMap[compiledMatch[1]] || `ABI ${compiledMatch[1]}`;\n const required = nodeVersionMap[requiredMatch[1]] || `ABI ${requiredMatch[1]}`;\n versionInfo = `\\nā•‘ Module compiled for Node.js ${compiled}, running Node.js ${required}`.padEnd(79) + 'ā•‘';\n }\n\n console.warn(`\n╔══════════════════════════════════════════════════════════════════════════════╗\nā•‘ Native Module Version Mismatch (NODE_MODULE_VERSION) ā•‘\n╠══════════════════════════════════════════════════════════════════════════════╣\nā•‘ ā•‘\nā•‘ The better-sqlite3 module was compiled for a different Node.js version. ā•‘${versionInfo}\nā•‘ ā•‘\nā•‘ Auto-rebuild was attempted but SQLite is still unavailable. ā•‘\nā•‘ Claude Flow will continue with JSON fallback storage (still works fine). ā•‘\nā•‘ ā•‘\nā•‘ To manually fix this and use SQLite: ā•‘\nā•‘ ā•‘\nā•‘ Option 1 - Global install (recommended): ā•‘\nā•‘ > npm install -g claude-flow@alpha ā•‘\nā•‘ ā•‘\nā•‘ Option 2 - Clear npx cache: ā•‘\nā•‘ > rm -rf ~/.npm/_npx/ && npx claude-flow@alpha ... ā•‘\nā•‘ ā•‘\nā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•\n`);\n return false;\n }\n\n // Check for other Windows/installation errors\n if (requireErr.message?.includes('Could not locate the bindings file') ||\n requireErr.message?.includes('The specified module could not be found') ||\n requireErr.code === 'MODULE_NOT_FOUND') {\n\n console.warn(`\n╔══════════════════════════════════════════════════════════════════════════════╗\nā•‘ SQLite Native Module Installation Issue ā•‘\n╠══════════════════════════════════════════════════════════════════════════════╣\nā•‘ ā•‘\nā•‘ The native SQLite module failed to load. This is common on Windows when ā•‘\nā•‘ using 'npx' or when node-gyp build tools are not available. ā•‘\nā•‘ ā•‘\nā•‘ Claude Flow will continue with JSON fallback storage (still works fine). ā•‘\nā•‘ ā•‘\nā•‘ To enable SQLite storage: ā•‘\nā•‘ ā•‘\nā•‘ Option 1 - Install Build Tools (Windows): ā•‘\nā•‘ > npm install --global windows-build-tools ā•‘\nā•‘ > npm install claude-flow@alpha ā•‘\nā•‘ ā•‘\nā•‘ Option 2 - Use WSL (Windows Subsystem for Linux): ā•‘\nā•‘ Install WSL and run Claude Flow inside a Linux environment ā•‘\nā•‘ ā•‘\nā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•\n`);\n }\n \n return false;\n }\n }\n}\n\n/**\n * Check if SQLite is available\n */\nexport async function isSQLiteAvailable() {\n if (sqliteAvailable !== null) {\n return sqliteAvailable;\n }\n \n await tryLoadSQLite();\n return sqliteAvailable;\n}\n\n/**\n * Get SQLite Database constructor or null\n */\nexport async function getSQLiteDatabase() {\n if (!sqliteAvailable && loadError === null) {\n await tryLoadSQLite();\n }\n \n return Database;\n}\n\n/**\n * Get the load error if any\n */\nexport function getLoadError() {\n return loadError;\n}\n\n/**\n * Create a SQLite database instance with fallback\n */\nexport async function createDatabase(dbPath) {\n const DB = await getSQLiteDatabase();\n\n if (!DB) {\n throw new Error('SQLite is not available. Use fallback storage instead.');\n }\n\n try {\n return new DB(dbPath);\n } catch (err) {\n // Check for NODE_MODULE_VERSION mismatch at instantiation time\n const isVersionMismatch =\n err.message?.includes('NODE_MODULE_VERSION') ||\n err.message?.includes('was compiled against a different Node.js version') ||\n err.code === 'ERR_DLOPEN_FAILED';\n\n if (isVersionMismatch && !rebuildAttempted) {\n // Try auto-rebuild\n if (tryRebuildBetterSqlite3()) {\n // Rebuild succeeded, try again\n try {\n const require = createRequire(import.meta.url);\n // Clear require cache\n const modulePath = require.resolve('better-sqlite3');\n delete require.cache[modulePath];\n // Also clear any cached .node files\n Object.keys(require.cache).forEach(key => {\n if (key.includes('better_sqlite3.node') || key.includes('better-sqlite3')) {\n delete require.cache[key];\n }\n });\n // Re-require and instantiate\n const NewDB = require('better-sqlite3');\n Database = NewDB;\n return new NewDB(dbPath);\n } catch (retryErr) {\n // Rebuild didn't help\n throw err;\n }\n }\n }\n\n // Additional Windows-specific error handling\n if (err.message?.includes('EPERM') || err.message?.includes('access denied')) {\n throw new Error(`Cannot create database at ${dbPath}. Permission denied. Try using a different directory or running with administrator privileges.`);\n }\n throw err;\n }\n}\n\n/**\n * Check if running on Windows\n */\nexport function isWindows() {\n return process.platform === 'win32';\n}\n\n/**\n * Get platform-specific storage recommendations\n */\nexport function getStorageRecommendations() {\n if (isWindows()) {\n return {\n recommended: 'in-memory',\n reason: 'Windows native module compatibility',\n alternatives: [\n 'Install Windows build tools for SQLite support',\n 'Use WSL (Windows Subsystem for Linux)',\n 'Use Docker container with Linux'\n ]\n };\n }\n \n return {\n recommended: 'sqlite',\n reason: 'Best performance and persistence',\n alternatives: ['in-memory for testing']\n };\n}\n\n// Pre-load SQLite on module import\ntryLoadSQLite().catch(() => {\n // Silently handle initial load failure\n});\n\nexport default {\n isSQLiteAvailable,\n getSQLiteDatabase,\n getLoadError,\n createDatabase,\n isWindows,\n getStorageRecommendations\n};"],"names":["createRequire","execSync","path","fileURLToPath","__filename","url","__dirname","dirname","Database","sqliteAvailable","loadError","rebuildAttempted","tryRebuildBetterSqlite3","require","betterSqlite3Path","resolve","console","warn","process","version","cwd","stdio","timeout","err","message","tryLoadSQLite","requireErr","module","default","importErr","isVersionMismatch","includes","modulePath","cache","retryErr","errorMsg","compiledMatch","match","requiredMatch","nodeVersionMap","versionInfo","compiled","required","padEnd","code","isSQLiteAvailable","getSQLiteDatabase","getLoadError","createDatabase","dbPath","DB","Error","Object","keys","forEach","key","NewDB","isWindows","platform","getStorageRecommendations","recommended","reason","alternatives","catch"],"mappings":"AAMA,SAASA,aAAa,QAAQ,SAAS;AACvC,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,OAAOC,UAAU,OAAO;AACxB,SAASC,aAAa,QAAQ,MAAM;AAEpC,MAAMC,aAAaD,cAAc,YAAYE,GAAG;AAChD,MAAMC,YAAYJ,KAAKK,OAAO,CAACH;AAE/B,IAAII,WAAW;AACf,IAAIC,kBAAkB;AACtB,IAAIC,YAAY;AAChB,IAAIC,mBAAmB;AAKvB,SAASC;IACP,IAAID,kBAAkB,OAAO;IAC7BA,mBAAmB;IAEnB,IAAI;QAEF,MAAME,UAAUb,cAAc,YAAYK,GAAG;QAC7C,MAAMS,oBAAoBZ,KAAKK,OAAO,CAACM,QAAQE,OAAO,CAAC;QAEvDC,QAAQC,IAAI,CAAC,CAAC,sDAAsD,EAAEC,QAAQC,OAAO,CAAC,GAAG,CAAC;QAG1FlB,SAAS,eAAe;YACtBmB,KAAKN;YACLO,OAAO;gBAAC;gBAAQ;gBAAQ;aAAO;YAC/BC,SAAS;QACX;QAEAN,QAAQC,IAAI,CAAC,CAAC,+CAA+C,CAAC;QAC9D,OAAO;IACT,EAAE,OAAOM,KAAK;QACZP,QAAQC,IAAI,CAAC,CAAC,yBAAyB,EAAEM,IAAIC,OAAO,EAAE;QACtDR,QAAQC,IAAI,CAAC,C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AAK,CAACD,WAAW;oBAEhCoB,OAAOC,IAAI,CAACxC,QAAQoB,KAAK,EAAEqB,OAAO,CAACC,CAAAA;wBACjC,IAAIA,IAAIxB,QAAQ,CAAC,0BAA0BwB,IAAIxB,QAAQ,CAAC,mBAAmB;4BACzE,OAAOlB,QAAQoB,KAAK,CAACsB,IAAI;wBAC3B;oBACF;oBAEA,MAAMC,QAAQ3C,QAAQ;oBACtBL,WAAWgD;oBACX,OAAO,IAAIA,MAAMP;gBACnB,EAAE,OAAOf,UAAU;oBAEjB,MAAMX;gBACR;YACF;QACF;QAGA,IAAIA,IAAIC,OAAO,EAAEO,SAAS,YAAYR,IAAIC,OAAO,EAAEO,SAAS,kBAAkB;YAC5E,MAAM,IAAIoB,MAAM,CAAC,0BAA0B,EAAEF,OAAO,8FAA8F,CAAC;QACrJ;QACA,MAAM1B;IACR;AACF;AAKA,OAAO,SAASkC;IACd,OAAOvC,QAAQwC,QAAQ,KAAK;AAC9B;AAKA,OAAO,SAASC;IACd,IAAIF,aAAa;QACf,OAAO;YACLG,aAAa;YACbC,QAAQ;YACRC,cAAc;gBACZ;gBACA;gBACA;aACD;QACH;IACF;IAEA,OAAO;QACLF,aAAa;QACbC,QAAQ;QACRC,cAAc;YAAC;SAAwB;IACzC;AACF;AAGArC,gBAAgBsC,KAAK,CAAC,KAEtB;AAEA,eAAe;IACblB;IACAC;IACAC;IACAC;IACAS;IACAE;AACF,EAAE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-flow",
3
- "version": "2.7.44",
3
+ "version": "2.7.46",
4
4
  "description": "Enterprise-grade AI agent orchestration with WASM-powered ReasoningBank memory and AgentDB vector database (always uses latest agentic-flow)",
5
5
  "mcpName": "io.github.ruvnet/claude-flow",
6
6
  "main": "cli.mjs",
@@ -1,9 +1,11 @@
1
1
  /**
2
2
  * SQLite Wrapper with Windows Fallback Support
3
3
  * Provides graceful fallback when better-sqlite3 fails to load
4
+ * Includes auto-rebuild for NODE_MODULE_VERSION mismatches
4
5
  */
5
6
 
6
7
  import { createRequire } from 'module';
8
+ import { execSync } from 'child_process';
7
9
  import path from 'path';
8
10
  import { fileURLToPath } from 'url';
9
11
 
@@ -13,6 +15,37 @@ const __dirname = path.dirname(__filename);
13
15
  let Database = null;
14
16
  let sqliteAvailable = false;
15
17
  let loadError = null;
18
+ let rebuildAttempted = false;
19
+
20
+ /**
21
+ * Attempt to rebuild better-sqlite3 for the current Node.js version
22
+ */
23
+ function tryRebuildBetterSqlite3() {
24
+ if (rebuildAttempted) return false;
25
+ rebuildAttempted = true;
26
+
27
+ try {
28
+ // Find the better-sqlite3 module path
29
+ const require = createRequire(import.meta.url);
30
+ const betterSqlite3Path = path.dirname(require.resolve('better-sqlite3/package.json'));
31
+
32
+ console.warn(`\nšŸ”§ Attempting to rebuild better-sqlite3 for Node.js ${process.version}...`);
33
+
34
+ // Run npm rebuild in the better-sqlite3 directory
35
+ execSync('npm rebuild', {
36
+ cwd: betterSqlite3Path,
37
+ stdio: ['pipe', 'pipe', 'pipe'],
38
+ timeout: 120000 // 2 minute timeout
39
+ });
40
+
41
+ console.warn(`āœ… Rebuild successful! Retrying SQLite load...\n`);
42
+ return true;
43
+ } catch (err) {
44
+ console.warn(`āš ļø Auto-rebuild failed: ${err.message}`);
45
+ console.warn(` You may need build tools installed (python, make, g++)\n`);
46
+ return false;
47
+ }
48
+ }
16
49
 
17
50
  /**
18
51
  * Try to load better-sqlite3 with comprehensive error handling
@@ -42,6 +75,24 @@ async function tryLoadSQLite() {
42
75
  importErr.message?.includes('was compiled against a different Node.js version');
43
76
 
44
77
  if (isVersionMismatch) {
78
+ // Try auto-rebuild first
79
+ if (!rebuildAttempted && tryRebuildBetterSqlite3()) {
80
+ // Rebuild succeeded, try loading again
81
+ try {
82
+ const require = createRequire(import.meta.url);
83
+ // Clear the require cache to pick up rebuilt module
84
+ const modulePath = require.resolve('better-sqlite3');
85
+ delete require.cache[modulePath];
86
+ Database = require('better-sqlite3');
87
+ sqliteAvailable = true;
88
+ loadError = null;
89
+ return true;
90
+ } catch (retryErr) {
91
+ // Rebuild succeeded but load still failed
92
+ loadError = retryErr;
93
+ }
94
+ }
95
+
45
96
  // Extract version info for helpful message
46
97
  const errorMsg = requireErr.message || importErr.message || '';
47
98
  const compiledMatch = errorMsg.match(/NODE_MODULE_VERSION (\d+)/);
@@ -65,18 +116,16 @@ async function tryLoadSQLite() {
65
116
  ā•‘ ā•‘
66
117
  ā•‘ The better-sqlite3 module was compiled for a different Node.js version. ā•‘${versionInfo}
67
118
  ā•‘ ā•‘
119
+ ā•‘ Auto-rebuild was attempted but SQLite is still unavailable. ā•‘
68
120
  ā•‘ Claude Flow will continue with JSON fallback storage (still works fine). ā•‘
69
121
  ā•‘ ā•‘
70
- ā•‘ To fix this and use SQLite: ā•‘
71
- ā•‘ ā•‘
72
- ā•‘ Option 1 - Rebuild the module: ā•‘
73
- ā•‘ > npm rebuild better-sqlite3 ā•‘
122
+ ā•‘ To manually fix this and use SQLite: ā•‘
74
123
  ā•‘ ā•‘
75
- ā•‘ Option 2 - Clear npx cache (if using npx): ā•‘
76
- ā•‘ > rm -rf ~/.npm/_npx/ && npx claude-flow@alpha ... ā•‘
124
+ ā•‘ Option 1 - Global install (recommended): ā•‘
125
+ ā•‘ > npm install -g claude-flow@alpha ā•‘
77
126
  ā•‘ ā•‘
78
- ā•‘ Option 3 - Reinstall dependencies: ā•‘
79
- ā•‘ > rm -rf node_modules && npm install ā•‘
127
+ ā•‘ Option 2 - Clear npx cache: ā•‘
128
+ ā•‘ > rm -rf ~/.npm/_npx/ && npx claude-flow@alpha ... ā•‘
80
129
  ā•‘ ā•‘
81
130
  ā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•
82
131
  `);
@@ -151,16 +200,48 @@ export function getLoadError() {
151
200
  */
152
201
  export async function createDatabase(dbPath) {
153
202
  const DB = await getSQLiteDatabase();
154
-
203
+
155
204
  if (!DB) {
156
205
  throw new Error('SQLite is not available. Use fallback storage instead.');
157
206
  }
158
-
207
+
159
208
  try {
160
209
  return new DB(dbPath);
161
210
  } catch (err) {
211
+ // Check for NODE_MODULE_VERSION mismatch at instantiation time
212
+ const isVersionMismatch =
213
+ err.message?.includes('NODE_MODULE_VERSION') ||
214
+ err.message?.includes('was compiled against a different Node.js version') ||
215
+ err.code === 'ERR_DLOPEN_FAILED';
216
+
217
+ if (isVersionMismatch && !rebuildAttempted) {
218
+ // Try auto-rebuild
219
+ if (tryRebuildBetterSqlite3()) {
220
+ // Rebuild succeeded, try again
221
+ try {
222
+ const require = createRequire(import.meta.url);
223
+ // Clear require cache
224
+ const modulePath = require.resolve('better-sqlite3');
225
+ delete require.cache[modulePath];
226
+ // Also clear any cached .node files
227
+ Object.keys(require.cache).forEach(key => {
228
+ if (key.includes('better_sqlite3.node') || key.includes('better-sqlite3')) {
229
+ delete require.cache[key];
230
+ }
231
+ });
232
+ // Re-require and instantiate
233
+ const NewDB = require('better-sqlite3');
234
+ Database = NewDB;
235
+ return new NewDB(dbPath);
236
+ } catch (retryErr) {
237
+ // Rebuild didn't help
238
+ throw err;
239
+ }
240
+ }
241
+ }
242
+
162
243
  // Additional Windows-specific error handling
163
- if (err.message.includes('EPERM') || err.message.includes('access denied')) {
244
+ if (err.message?.includes('EPERM') || err.message?.includes('access denied')) {
164
245
  throw new Error(`Cannot create database at ${dbPath}. Permission denied. Try using a different directory or running with administrator privileges.`);
165
246
  }
166
247
  throw err;