instar 0.23.10 → 0.23.12

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/dist/cli.js CHANGED
File without changes
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAwPH,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AA8gCD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAk3EtE;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAsDzE;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuD5E"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAwPH,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAiiCD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAk3EtE;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAsDzE;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuD5E"}
@@ -1006,15 +1006,22 @@ async function ensureAgentUpdatesTopic(telegram, state) {
1006
1006
  */
1007
1007
  async function ensureSqliteBindings() {
1008
1008
  try {
1009
- await import('better-sqlite3');
1010
- // Bindings loaded OKnothing to do.
1009
+ const BetterSqlite3 = (await import('better-sqlite3')).default;
1010
+ // Import alone doesn't catch all mismatches some NODE_MODULE_VERSION
1011
+ // conflicts cause runtime crashes (C++ mutex errors) rather than import errors.
1012
+ // Actually opening an in-memory DB exercises the native bindings fully.
1013
+ const testDb = new BetterSqlite3(':memory:');
1014
+ testDb.pragma('journal_mode = WAL');
1015
+ testDb.close();
1011
1016
  return false;
1012
1017
  }
1013
1018
  catch (err) {
1014
1019
  const reason = err instanceof Error ? err.message : String(err);
1015
1020
  const isBindingError = reason.includes('Could not locate the bindings file') ||
1016
1021
  reason.includes('better-sqlite3') ||
1017
- reason.includes('was compiled against a different Node.js version');
1022
+ reason.includes('was compiled against a different Node.js version') ||
1023
+ reason.includes('NODE_MODULE_VERSION') ||
1024
+ reason.includes('mutex lock failed');
1018
1025
  if (!isBindingError)
1019
1026
  return false; // Not a binding issue — let subsystems handle it.
1020
1027
  console.log(pc.yellow(' better-sqlite3: native binding mismatch detected — auto-rebuilding for current Node.js version...'));
@@ -1026,14 +1033,27 @@ async function ensureSqliteBindings() {
1026
1033
  execFileSync(process.execPath, [fixScript], { encoding: 'utf-8', timeout: 60000, stdio: 'pipe' });
1027
1034
  }
1028
1035
  else {
1029
- // Fallback: npm rebuild (may fail in pnpm/asdf environments)
1030
- const globalInstarDir = execSync('npm root -g', { encoding: 'utf-8', timeout: 10000 }).trim() + '/instar';
1031
- execSync('npm rebuild better-sqlite3', {
1032
- cwd: globalInstarDir,
1033
- encoding: 'utf-8',
1034
- timeout: 60000,
1035
- stdio: 'pipe',
1036
- });
1036
+ // Fallback: npm rebuild in the directory containing better-sqlite3.
1037
+ // Shadow installs have their own node_modules try that first, then global.
1038
+ const instarDir = new URL('../../..', import.meta.url).pathname;
1039
+ const shadowBs3 = path.join(instarDir, 'node_modules', 'better-sqlite3');
1040
+ if (fs.existsSync(shadowBs3)) {
1041
+ execSync('npm rebuild better-sqlite3', {
1042
+ cwd: instarDir,
1043
+ encoding: 'utf-8',
1044
+ timeout: 60000,
1045
+ stdio: 'pipe',
1046
+ });
1047
+ }
1048
+ else {
1049
+ const globalInstarDir = execSync('npm root -g', { encoding: 'utf-8', timeout: 10000 }).trim() + '/instar';
1050
+ execSync('npm rebuild better-sqlite3', {
1051
+ cwd: globalInstarDir,
1052
+ encoding: 'utf-8',
1053
+ timeout: 60000,
1054
+ stdio: 'pipe',
1055
+ });
1056
+ }
1037
1057
  }
1038
1058
  console.log(pc.green(' better-sqlite3: rebuilt successfully — restarting to apply (ESM module cache must be cleared).'));
1039
1059
  return true; // Restart needed — ESM cache holds the stale failure