const { spawn } = require('child_process');
const path = require('path');
const os = require('os');
const platform = os.platform();
const arch = os.arch();
let binaryName = 'temporal-solver';
if (platform === 'win32') {
binaryName += '.exe';
}
const binaryPath = path.join(__dirname, '..', 'target', 'release', binaryName);
function hasAVX2Support() {
try {
const cpuInfo = require('os').cpus()[0].model;
return !cpuInfo.includes('ARM') && !cpuInfo.includes('Apple M');
} catch {
return false;
}
}
const args = process.argv.slice(2);
if (hasAVX2Support()) {
console.log('✅ AVX2 support detected - using optimized path');
} else {
console.log('⚠️ AVX2 not detected - using fallback implementation');
}
const child = spawn(binaryPath, args, {
stdio: 'inherit',
env: {
...process.env,
RUST_BACKTRACE: '1'
}
});
child.on('error', (err) => {
if (err.code === 'ENOENT') {
console.error('❌ Binary not found. Please run: npm run build');
process.exit(1);
}
console.error('Error:', err);
process.exit(1);
});
child.on('exit', (code) => {
process.exit(code || 0);
});