aurix-ai 2.7.7 → 2.7.9

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/aurix.js CHANGED
@@ -19,23 +19,55 @@ try {
19
19
  runtime = 'bun';
20
20
  } catch {}
21
21
 
22
+ // Use shell: false with an absolute path to the Node binary. shell: true
23
+ // triggers DEP0190 (args concatenated without escaping). process.execPath
24
+ // points at the real node.exe even when launched through a .cmd shim on
25
+ // Windows, so spawn() works without shell: true.
26
+ let runtimeBin = process.execPath;
27
+ if (runtime === 'bun') {
28
+ try {
29
+ runtimeBin = execSync('bun -e "process.stdout.write(process.execPath)"', { encoding: 'utf8' }).trim() || 'bun';
30
+ } catch {
31
+ runtimeBin = 'bun';
32
+ }
33
+ }
34
+
22
35
  const nodeArgs = [];
23
- if (runtime === 'node') {
24
- // node:ffi is still experimental in Node 22.5+ / 24.x. Without this flag,
25
- // OpenTUI's backend loader falls back to an "FFI unavailable" stub and the
26
- // whole TUI refuses to start (this is what bit us on Windows).
27
- // Don't double-inject if the user (or a parent process) already passed it.
28
- const execArgv = process.execArgv || [];
29
- const hasFlag = execArgv.some(a =>
30
- a === '--experimental-ffi' || a.startsWith('--experimental-ffi=')
31
- );
32
- if (!hasFlag) nodeArgs.push('--experimental-ffi');
36
+ let selfRelaunch = false;
37
+
38
+ if (runtime === 'node' && !process.env.AURIX_RELAUNCHED) {
39
+ // OpenTUI's backend does `require("node:ffi")` which is experimental in
40
+ // Node 22.5+. Probe whether it already works without a flag, and only
41
+ // inject --experimental-ffi if it actually fails AND the flag is valid
42
+ // on this Node build. If neither works, launch without the flag and let
43
+ // the in-process fallback render a diagnostic message.
44
+ let needsFlag = false;
45
+ try {
46
+ execSync(`"${runtimeBin}" -e "require(\\"node:ffi\\")"`, { stdio: 'ignore' });
47
+ } catch {
48
+ needsFlag = true;
49
+ }
50
+
51
+ if (needsFlag) {
52
+ let flagWorks = false;
53
+ try {
54
+ execSync(`"${runtimeBin}" --experimental-ffi -e "0"`, { stdio: 'ignore' });
55
+ flagWorks = true;
56
+ } catch {}
57
+
58
+ if (flagWorks) {
59
+ nodeArgs.push('--experimental-ffi');
60
+ selfRelaunch = true;
61
+ }
62
+ }
33
63
  }
34
64
 
35
- const child = spawn(runtime, [...nodeArgs, dist, ...process.argv.slice(2)], {
65
+ const env = { ...process.env, AURIX_HOME: join(__dirname, '..') };
66
+ if (selfRelaunch) env.AURIX_RELAUNCHED = '1';
67
+
68
+ const child = spawn(runtimeBin, [...nodeArgs, dist, ...process.argv.slice(2)], {
36
69
  stdio: 'inherit',
37
- env: { ...process.env, AURIX_HOME: join(__dirname, '..') },
38
- shell: process.platform === 'win32',
70
+ env,
39
71
  });
40
72
 
41
73
  child.on('close', (code) => process.exit(code ?? 0));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aurix-ai",
3
- "version": "2.7.7",
3
+ "version": "2.7.9",
4
4
  "description": "Open-source terminal AI agent for coding, deep research, automation, and multi-platform task execution.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,63 +1,86 @@
1
1
  #!/usr/bin/env node
2
- import { readFileSync, writeFileSync, existsSync } from 'fs';
2
+ // Runs automatically after `npm install` (postinstall hook).
3
+ // Fixes the two things that commonly break aurix on Windows:
4
+ // 1. @opentui/core-win32-x64 optional dependency sometimes gets skipped
5
+ // (network glitch, --omit=optional, pnpm strict).
6
+ // 2. Bun runtime (preferred over Node because it has built-in FFI,
7
+ // no --experimental-ffi flag needed).
8
+ // Safe to re-run; idempotent and skips when already satisfied.
9
+
10
+ import { existsSync } from 'fs';
3
11
  import { join, dirname } from 'path';
4
12
  import { fileURLToPath } from 'url';
13
+ import { spawnSync, execSync } from 'child_process';
5
14
 
6
15
  const __dirname = dirname(fileURLToPath(import.meta.url));
16
+ const projectRoot = join(__dirname, '..');
7
17
 
8
- console.log('\n╔═══════════════════════════════════════════════════════════╗');
9
- console.log('║ Aurix Agent - Post-install Setup ║');
10
- console.log('╚═══════════════════════════════════════════════════════════╝\n');
18
+ function log(msg) { console.log(`[aurix postinstall] ${msg}`); }
19
+ function run(cmd, args, opts = {}) {
20
+ return spawnSync(cmd, args, { stdio: 'inherit', ...opts }).status === 0;
21
+ }
11
22
 
12
- const results = [];
23
+ // ─── 1. Ensure native OpenTUI binary is installed (Windows only) ───────────
24
+ if (process.platform === 'win32') {
25
+ const pkgName = process.arch === 'arm64'
26
+ ? '@opentui/core-win32-arm64'
27
+ : '@opentui/core-win32-x64';
28
+ const expected = join(projectRoot, 'node_modules', '@opentui', pkgName.replace('@opentui/', ''));
13
29
 
14
- try {
15
- console.log('[1/2] Patching react-reconciler for ESM compatibility...');
16
- const pkgPath = join(__dirname, '..', 'node_modules', 'react-reconciler', 'package.json');
17
- const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
18
- if (!pkg.exports) {
19
- pkg.exports = {
20
- '.': './index.js',
21
- './constants': './constants.js',
22
- './reflection': './reflection.js',
23
- './package.json': './package.json',
24
- };
25
- writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n', 'utf-8');
26
- console.log(' ✓ React-reconciler patched\n');
27
- results.push(['React-reconciler patch', 'success']);
30
+ if (existsSync(expected)) {
31
+ log(`✓ ${pkgName} already installed`);
28
32
  } else {
29
- console.log(' ✓ Already patched\n');
30
- results.push(['React-reconciler patch', 'skipped']);
33
+ log(`⚠ ${pkgName} missing — installing (this optionalDependency is sometimes skipped by npm)`);
34
+ // shell:true needed on Windows so `npm` resolves through npm.cmd
35
+ const ok = run('npm', [
36
+ 'install', '--no-save', '--no-audit', '--no-fund', `${pkgName}@0.4.1`,
37
+ ], { cwd: projectRoot, shell: true });
38
+ if (!ok) log(`⚠ failed to install ${pkgName} — TUI may fail to start`);
39
+ else log(`✓ ${pkgName} installed`);
31
40
  }
32
- } catch (e) {
33
- console.warn(' ⚠ Could not patch react-reconciler:', e.message, '\n');
34
- results.push(['React-reconciler patch', 'failed']);
35
41
  }
36
42
 
43
+ // ─── 2. Hint about Bun (don't auto-install on Windows — UAC prompt) ───────
37
44
  try {
38
- console.log('[2/2] Downloading CloakBrowser stealth Chromium binary...');
39
- console.log(' (This may take 1-2 minutes on first install)');
40
- const { ensureBinary } = await import('cloakbrowser');
41
- const binaryPath = await ensureBinary();
42
- console.log(' ✓ CloakBrowser binary ready:', binaryPath, '\n');
43
- results.push(['CloakBrowser binary', 'success']);
44
- } catch (e) {
45
- console.warn(' ⚠ CloakBrowser binary download skipped:', e.message);
46
- console.warn(' Browser automation features will not be available.');
47
- console.warn(' To fix: ensure internet access and run "npm install" again.\n');
48
- results.push(['CloakBrowser binary', 'failed']);
45
+ execSync('bun --version', { stdio: 'ignore' });
46
+ log(' Bun already installed');
47
+ } catch {
48
+ if (process.platform === 'win32') {
49
+ log('');
50
+ log(' Bun not found. Bun is RECOMMENDED on Windows because it has');
51
+ log(' built-in FFI (no --experimental-ffi flag needed).');
52
+ log('');
53
+ log(' To install, run in PowerShell:');
54
+ log(' powershell -c "irm bun.sh/install.ps1 | iex"');
55
+ log('');
56
+ log(' Skipping auto-install to avoid UAC prompts in non-interactive mode.');
57
+ } else {
58
+ log('Installing Bun...');
59
+ if (run('bash', ['-c', 'curl -fsSL https://bun.sh/install | bash'])) {
60
+ log('✓ Bun installed');
61
+ } else {
62
+ log('⚠ Bun install failed — aurix will fall back to Node');
63
+ }
64
+ }
49
65
  }
50
66
 
51
- console.log('╔═══════════════════════════════════════════════════════════╗');
52
- console.log('║ Installation Summary ║');
53
- console.log('╚═══════════════════════════════════════════════════════════╝');
54
-
55
- for (const [name, status] of results) {
56
- const icon = status === 'success' ? '✓' : status === 'skipped' ? '⊘' : '⚠';
57
- console.log(` ${icon} ${name}: ${status}`);
67
+ // ─── 3. Node FFI probe (informative) ──────────────────────────────────────
68
+ try {
69
+ execSync(`"${process.execPath}" -e "require(\\"node:ffi\\")"`, { stdio: 'ignore' });
70
+ log('✓ node:ffi available without flag');
71
+ } catch {
72
+ let flagWorks = false;
73
+ try {
74
+ execSync(`"${process.execPath}" --experimental-ffi -e "0"`, { stdio: 'ignore' });
75
+ flagWorks = true;
76
+ } catch {}
77
+ if (flagWorks) {
78
+ log('ℹ node:ffi requires --experimental-ffi (launcher injects it automatically)');
79
+ } else {
80
+ log('⚠ node:ffi not available on this Node build.');
81
+ log(' Install Bun (recommended) or use official Node from nodejs.org.');
82
+ }
58
83
  }
59
84
 
60
- console.log('\n╔═══════════════════════════════════════════════════════════╗');
61
- console.log('║ Setup complete! Run "aurix" to start the agent.');
62
- console.log('║ For issues: https://github.com/DekaPrayoga/AurixAgent ║');
63
- console.log('╚═══════════════════════════════════════════════════════════╝\n');
85
+ log('');
86
+ log(' postinstall complete. Run `aurix` to start.');