4runr-os 2.1.21 → 2.1.23

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/README.md CHANGED
@@ -1,150 +1,65 @@
1
- # 4Runr OS - AI Agent Operating System
1
+ # 4Runr OS
2
2
 
3
- Interactive terminal for managing AI agents on the 4Runr platform.
3
+ Modern Terminal Interface for the 4Runr AI Agent OS.
4
4
 
5
- ## Installation
5
+ ## Quick Start
6
6
 
7
- Install globally from npm:
7
+ ### One-Time Setup
8
8
 
9
9
  ```bash
10
10
  npm install -g 4runr-os
11
11
  ```
12
12
 
13
- ## Quick Start
14
-
15
- After installation, simply run:
13
+ ### Daily Use
16
14
 
17
15
  ```bash
18
16
  4r
19
17
  ```
20
18
 
21
- That's it! The OS connects to the official 4Runr server automatically.
19
+ **That's it!** No other setup needed.
22
20
 
23
- ## Available Commands
21
+ ---
24
22
 
25
- You can use any of these commands:
26
- - `4r` - Short and simple (recommended)
27
- - `4runr` - Full command
28
- - `4runr-os` - Full package name
23
+ ## Features
29
24
 
30
- All commands do the same thing - launch the 4Runr OS terminal.
25
+ - 🚀 **Modern TUI** - Beautiful Rust-based terminal interface
26
+ - 🔄 **Auto-Updates** - Automatically updates when new versions are available
27
+ - 🎯 **Zero Config** - Works out of the box
28
+ - 🪶 **Lightweight** - Fast and efficient
31
29
 
32
- ### Connect to Local Server (Development)
30
+ ## Commands
33
31
 
34
- If you're running a local gateway, set the `GATEWAY_URL` environment variable:
32
+ - `4r` - Launch the 4Runr OS terminal interface
33
+ - `4runr` - Alias for `4r`
34
+ - `4runr-os` - Alias for `4r`
35
35
 
36
- **Windows (PowerShell):**
37
- ```powershell
38
- $env:GATEWAY_URL="http://localhost:3001"
39
- 4runr
40
- ```
36
+ ## Auto-Update
41
37
 
42
- **Windows (CMD):**
43
- ```cmd
44
- set GATEWAY_URL=http://localhost:3001
45
- 4runr
46
- ```
38
+ The `4r` command automatically checks for updates and installs them if available. You can control this behavior:
47
39
 
48
- **Linux/Mac:**
49
40
  ```bash
50
- export GATEWAY_URL=http://localhost:3001
51
- 4runr
52
- ```
41
+ # Disable auto-update (still checks)
42
+ NO_AUTO_UPDATE=1 4r
53
43
 
54
- ### Connect to Custom Server
44
+ # Disable update check entirely
45
+ NO_UPDATE_CHECK=1 4r
55
46
 
56
- To use a different server, set `GATEWAY_URL`:
57
- ```bash
58
- export GATEWAY_URL=http://your-server.com:3001
59
- 4runr
47
+ # Or use the config command inside the OS
48
+ 4r
49
+ # Then: config auto-update disable
60
50
  ```
61
51
 
62
- ### Quick Start
63
-
64
- 1. **Configure AI Provider:**
65
- ```
66
- 4runr> config
67
- ```
68
- Follow the prompts to add your OpenAI or Anthropic API key.
69
-
70
- 2. **Start Chatting:**
71
- ```
72
- 4runr> run-agent assistant
73
- ```
74
- Then just type your messages!
75
-
76
- 3. **Build Custom Agent:**
77
- ```
78
- 4runr> build
79
- ```
80
- Create your own AI agent with custom system prompts.
81
-
82
- ## Available Commands
83
-
84
- ### AI Configuration
85
- - `config` - Configure AI provider (OpenAI/Anthropic)
86
- - `models` - List available AI models
87
- - `ai-status` - Show stored API keys and configuration
88
-
89
- ### Agent Management
90
- - `run-agent [name]` - Start chatting with an AI agent
91
- - `build` - Build a custom AI agent (interactive)
92
- - `agents` - List available agents
93
-
94
- ### Run Management
95
- - `create <name>` - Create a new run
96
- - `start <run-id>` - Start a run
97
- - `get <run-id>` - Get run details
98
- - `list` - List all runs
99
-
100
- ### System
101
- - `status` - Show system status
102
- - `sentinel` - Show Sentinel monitoring
103
- - `metrics` - Show system metrics
104
- - `clear` - Clear the screen
105
- - `help` - Show all commands
106
- - `exit` - Exit the OS
107
-
108
- ## Examples
109
-
110
- ### Connect to Server and Configure
111
-
112
- ```bash
113
- # Set server URL
114
- export GATEWAY_URL=http://44.222.212.152:3001
115
-
116
- # Run OS
117
- 4runr
118
-
119
- # Configure OpenAI
120
- 4runr> config
121
- # Follow prompts...
52
+ ## Requirements
122
53
 
123
- # Start chatting
124
- 4runr> run-agent assistant
125
- Assistant> Hello! How can I help you?
126
- ```
54
+ - **Node.js** 18.0.0 or higher
55
+ - **npm** (comes with Node.js)
127
56
 
128
- ### Build Custom Agent
57
+ **No Rust or build tools needed!** Pre-built binaries are included for Windows, Linux, and macOS.
129
58
 
130
- ```
131
- 4runr> build
132
- Agent name: code-reviewer
133
- Agent description: Reviews code for bugs and improvements
134
- System prompt: You are an expert code reviewer...
135
- END
136
- Temperature: 0.3
137
- Max tokens: 2000
138
-
139
- 4runr> run-agent code-reviewer
140
- ```
59
+ ## Troubleshooting
141
60
 
142
- ## Requirements
143
-
144
- - Node.js 18+
145
- - Access to a 4Runr Gateway (local or remote)
61
+ See [SETUP.md](./SETUP.md) for detailed setup instructions and troubleshooting.
146
62
 
147
63
  ## License
148
64
 
149
65
  MIT
150
-
package/SETUP.md ADDED
@@ -0,0 +1,86 @@
1
+ # 4Runr OS - Quick Setup Guide
2
+
3
+ ## One-Time Setup (Choose Your Platform)
4
+
5
+ ### Windows
6
+
7
+ ```powershell
8
+ # Install 4runr-os
9
+ npm install -g 4runr-os
10
+
11
+ # Done! Now just use:
12
+ 4r
13
+ ```
14
+
15
+ **That's it!** The package includes pre-built Windows binaries, so no Rust or build tools needed.
16
+
17
+ ---
18
+
19
+ ### Linux / macOS
20
+
21
+ ```bash
22
+ # Install 4runr-os
23
+ npm install -g 4runr-os
24
+
25
+ # Done! Now just use:
26
+ 4r
27
+ ```
28
+
29
+ **That's it!** The package includes pre-built binaries for Linux and macOS.
30
+
31
+ ---
32
+
33
+ ## After Setup
34
+
35
+ Once installed, just run:
36
+
37
+ ```bash
38
+ 4r
39
+ ```
40
+
41
+ That's all you need! The `4r` command will:
42
+ - ✅ Launch the 4Runr OS terminal interface
43
+ - ✅ Auto-update when new versions are available
44
+ - ✅ Work immediately (no additional setup needed)
45
+
46
+ ---
47
+
48
+ ## Troubleshooting
49
+
50
+ ### "4r: command not found"
51
+
52
+ Make sure npm global bin is in your PATH:
53
+
54
+ **Windows:**
55
+ ```powershell
56
+ # Add to PATH (add to your PowerShell profile)
57
+ $env:Path += ";$env:APPDATA\npm"
58
+ ```
59
+
60
+ **Linux/macOS:**
61
+ ```bash
62
+ # Add to PATH (add to ~/.bashrc or ~/.zshrc)
63
+ export PATH=$PATH:$(npm config get prefix)/bin
64
+ ```
65
+
66
+ ### "mk3-tui binary not found"
67
+
68
+ If you see this error, the package will automatically try to build from source:
69
+
70
+ **Windows:**
71
+ - Install Visual Studio Build Tools: https://visualstudio.microsoft.com/downloads/
72
+ - Or use GNU toolchain: `rustup toolchain install stable-x86_64-pc-windows-gnu && rustup default stable-x86_64-pc-windows-gnu`
73
+
74
+ **Linux/macOS:**
75
+ - Install Rust: `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`
76
+ - Then run `4r` again - it will build automatically
77
+
78
+ ---
79
+
80
+ ## That's It!
81
+
82
+ - **One-time setup**: `npm install -g 4runr-os`
83
+ - **Daily use**: `4r`
84
+
85
+ No other commands needed! 🚀
86
+
package/dist/index.js CHANGED
@@ -2519,19 +2519,24 @@ else {
2519
2519
  const __dirname = dirname(__filename);
2520
2520
  // Try to find mk3-tui binary in multiple locations
2521
2521
  const binaryName = process.platform === 'win32' ? 'mk3-tui.exe' : 'mk3-tui';
2522
+ const platform = process.platform;
2523
+ const arch = process.arch;
2524
+ const platformKey = `${platform}-${arch}`;
2522
2525
  const possiblePaths = [
2523
- // From npm package 4runr-os-mk3 (global install) - binary is in PATH as 'mk3-tui'
2524
- binaryName,
2525
- // From npm package 4runr-os-mk3 (local node_modules via dependency)
2526
- path.join(__dirname, '..', 'node_modules', '4runr-os-mk3', 'target', 'release', binaryName),
2526
+ // Pre-built binaries included in npm package (EASIEST - no build needed!)
2527
+ path.join(__dirname, '..', 'mk3-tui', 'binaries', platformKey, binaryName),
2528
+ path.join(__dirname, '..', 'mk3-tui', 'binaries', platform, binaryName), // Fallback to platform only
2529
+ // Built from source in package (postinstall)
2530
+ path.join(__dirname, '..', 'mk3-tui', 'target', 'release', binaryName),
2527
2531
  // From local build in monorepo (development)
2528
2532
  path.join(__dirname, '..', '..', '..', 'apps', 'mk3-tui', 'target', 'release', binaryName),
2529
- // From npm package 4runr-os-mk3 (local node_modules at root)
2530
- path.join(__dirname, '..', '..', '..', 'node_modules', '4runr-os-mk3', 'target', 'release', binaryName),
2533
+ // Fallback: try PATH (for backwards compatibility)
2534
+ binaryName,
2531
2535
  ];
2532
2536
  let binaryPath = null;
2533
2537
  for (const testPath of possiblePaths) {
2534
- if (testPath.includes('node_modules') || testPath.includes('apps')) {
2538
+ // Check if it's an absolute path (contains path separators)
2539
+ if (testPath.includes(path.sep) || testPath.includes('/') || testPath.includes('\\')) {
2535
2540
  // Absolute path - check if exists
2536
2541
  if (fs.existsSync(testPath)) {
2537
2542
  binaryPath = testPath;
@@ -2542,7 +2547,8 @@ else {
2542
2547
  // Try to find in PATH
2543
2548
  try {
2544
2549
  const { execSync } = await import('child_process');
2545
- execSync(`which ${testPath}`, { stdio: 'ignore' });
2550
+ const whichCmd = process.platform === 'win32' ? 'where' : 'which';
2551
+ execSync(`${whichCmd} ${testPath}`, { stdio: 'ignore' });
2546
2552
  binaryPath = testPath;
2547
2553
  break;
2548
2554
  }
@@ -2555,135 +2561,108 @@ else {
2555
2561
  const platform = process.platform;
2556
2562
  const isWindows = platform === 'win32';
2557
2563
  process.stderr.write('\n[ERROR] mk3-tui binary not found.\n');
2558
- if (isWindows) {
2559
- process.stderr.write('\n⚠️ Windows binary not yet available in npm package.\n');
2560
- process.stderr.write(' The current package only includes Linux binaries.\n\n');
2561
- // Check if Rust is installed
2562
- const { checkAndInstallRust } = await import('./rust-check.js');
2563
- const autoInstallRust = process.env.AUTO_INSTALL_RUST === '1';
2564
- const rustInstalled = await checkAndInstallRust(autoInstallRust);
2565
- if (rustInstalled) {
2566
- process.stderr.write('\n✅ Rust is installed! Building mk3-tui from npm package...\n\n');
2567
- // Try to build from npm package
2568
- try {
2569
- const { execSync } = await import('child_process');
2570
- const npmPackagePath = path.join(__dirname, '..', 'node_modules', '4runr-os-mk3');
2571
- if (fs.existsSync(npmPackagePath)) {
2572
- process.stderr.write('🔨 Building from npm package...\n');
2573
- execSync('cargo build --release', {
2574
- cwd: npmPackagePath,
2575
- stdio: 'inherit',
2564
+ // Check if Rust is installed and try to build
2565
+ const { checkAndInstallRust, getRustInstallCommand } = await import('./rust-check.js');
2566
+ const autoInstallRust = process.env.AUTO_INSTALL_RUST === '1';
2567
+ const rustInstalled = await checkAndInstallRust(autoInstallRust);
2568
+ if (rustInstalled) {
2569
+ process.stderr.write('\n✅ Rust is installed! Building mk3-tui from 4runr-os package...\n\n');
2570
+ // Try to build from 4runr-os package (mk3-tui is included)
2571
+ try {
2572
+ const { execSync } = await import('child_process');
2573
+ const mk3Path = path.join(__dirname, '..', 'mk3-tui');
2574
+ if (fs.existsSync(mk3Path)) {
2575
+ process.stderr.write('🔨 Building from 4runr-os package...\n');
2576
+ try {
2577
+ // Use spawn to show output AND capture errors
2578
+ const { spawn } = await import('child_process');
2579
+ const cargoProcess = spawn('cargo', ['build', '--release'], {
2580
+ cwd: mk3Path,
2581
+ stdio: ['ignore', 'inherit', 'pipe'], // stdin: ignore, stdout: inherit (show), stderr: pipe (capture)
2582
+ });
2583
+ let stderrOutput = '';
2584
+ cargoProcess.stderr.on('data', (data) => {
2585
+ const text = data.toString();
2586
+ stderrOutput += text;
2587
+ // Also show errors to user
2588
+ process.stderr.write(text);
2589
+ });
2590
+ await new Promise((resolve, reject) => {
2591
+ cargoProcess.on('close', (code) => {
2592
+ if (code !== 0) {
2593
+ reject({ code, stderrOutput, message: `cargo build failed with code ${code}` });
2594
+ }
2595
+ else {
2596
+ resolve();
2597
+ }
2598
+ });
2599
+ cargoProcess.on('error', (err) => {
2600
+ reject({ ...err, stderrOutput });
2601
+ });
2576
2602
  });
2577
- // Retry finding binary
2578
- const builtBinary = path.join(npmPackagePath, 'target', 'release', binaryName);
2579
- if (fs.existsSync(builtBinary)) {
2580
- binaryPath = builtBinary;
2581
- process.stderr.write('\n✅ Build successful! Launching...\n\n');
2582
- }
2583
- else {
2584
- process.stderr.write('\n⚠️ Build completed but binary not found at expected location.\n');
2585
- process.stderr.write(' Please try running "4r" again.\n\n');
2586
- process.exit(1);
2587
- }
2588
2603
  }
2589
- else {
2590
- process.stderr.write('\n⚠️ 4runr-os-mk3 package not found in node_modules.\n');
2591
- process.stderr.write(' Installing...\n\n');
2592
- execSync('npm install -g 4runr-os-mk3', { stdio: 'inherit' });
2593
- // The postinstall script should have built it, try to find it
2594
- const globalPath = process.platform === 'win32'
2595
- ? path.join(process.env.APPDATA || '', 'npm', 'node_modules', '4runr-os-mk3', 'target', 'release', binaryName)
2596
- : path.join('/usr/local/lib/node_modules', '4runr-os-mk3', 'target', 'release', binaryName);
2597
- if (fs.existsSync(globalPath)) {
2598
- binaryPath = globalPath;
2599
- }
2600
- else {
2601
- // Try PATH
2602
- try {
2603
- const whichCmd = platform === 'win32' ? 'where' : 'which';
2604
- execSync(`${whichCmd} ${binaryName}`, { stdio: 'ignore' });
2605
- binaryPath = binaryName;
2606
- }
2607
- catch {
2608
- process.stderr.write('\n⚠️ Please restart your terminal and run "4r" again.\n\n');
2609
- process.exit(1);
2610
- }
2611
- }
2604
+ catch (buildExecError) {
2605
+ // Attach captured stderr to error
2606
+ throw { ...buildExecError, buildOutput: buildExecError.stderrOutput || '' };
2612
2607
  }
2613
- }
2614
- catch (buildError) {
2615
- process.stderr.write('\n⚠️ Build failed. You can build manually:\n');
2616
- process.stderr.write(' cd %APPDATA%\\npm\\node_modules\\4runr-os-mk3\n');
2617
- process.stderr.write(' cargo build --release\n');
2618
- process.stderr.write(' Then run: 4r\n\n');
2619
- process.exit(1);
2620
- }
2621
- }
2622
- else {
2623
- process.stderr.write(' To use 4runr-os on Windows, you have two options:\n\n');
2624
- process.stderr.write(' Option 1: Install Rust and build locally\n');
2625
- process.stderr.write(' 1. Install Rust (see instructions above)\n');
2626
- process.stderr.write(' 2. Build: cd %USERPROFILE% && git clone https://github.com/KyanBergeron4Runr/4Runr-AI-Agent-OS.git\n');
2627
- process.stderr.write(' 3. Build: cd 4Runr-AI-Agent-OS\\apps\\mk3-tui && cargo build --release\n');
2628
- process.stderr.write(' 4. Add to PATH or run: .\\target\\release\\mk3-tui.exe\n\n');
2629
- process.stderr.write(' Option 2: Use WSL (Windows Subsystem for Linux)\n');
2630
- process.stderr.write(' 1. Install WSL: wsl --install\n');
2631
- process.stderr.write(' 2. In WSL: npm install -g 4runr-os\n');
2632
- process.stderr.write(' 3. Run: 4r\n\n');
2633
- process.stderr.write(' Windows binary support coming soon!\n\n');
2634
- }
2635
- }
2636
- else {
2637
- process.stderr.write('The 4runr-os package requires 4runr-os-mk3.\n');
2638
- process.stderr.write('Installing automatically...\n\n');
2639
- try {
2640
- // Try to install 4runr-os-mk3 automatically
2641
- const { execSync } = await import('child_process');
2642
- execSync('npm install -g 4runr-os-mk3', { stdio: 'inherit' });
2643
- // Retry finding binary after install
2644
- const retryPaths = [
2645
- binaryName,
2646
- path.join(__dirname, '..', 'node_modules', '4runr-os-mk3', 'target', 'release', binaryName),
2647
- ];
2648
- for (const testPath of retryPaths) {
2649
- if (testPath === binaryName) {
2650
- try {
2651
- const whichCmd = platform === 'win32' ? 'where' : 'which';
2652
- execSync(`${whichCmd} ${testPath}`, { stdio: 'ignore' });
2653
- binaryPath = testPath;
2654
- break;
2655
- }
2656
- catch {
2657
- continue;
2658
- }
2608
+ // Retry finding binary
2609
+ const builtBinary = path.join(mk3Path, 'target', 'release', binaryName);
2610
+ if (fs.existsSync(builtBinary)) {
2611
+ binaryPath = builtBinary;
2612
+ process.stderr.write('\n✅ Build successful! Launching...\n\n');
2659
2613
  }
2660
- else if (fs.existsSync(testPath)) {
2661
- binaryPath = testPath;
2662
- break;
2614
+ else {
2615
+ process.stderr.write('\n⚠️ Build completed but binary not found at expected location.\n');
2616
+ process.stderr.write(' Please try running "4r" again.\n\n');
2617
+ process.exit(1);
2663
2618
  }
2664
2619
  }
2665
- if (!binaryPath) {
2666
- process.stderr.write('\n[ERROR] Installation completed but binary still not found.\n');
2667
- process.stderr.write('Please run: npm install -g 4runr-os-mk3\n');
2668
- process.stderr.write('Then try again: 4r\n\n');
2620
+ else {
2621
+ process.stderr.write('\n⚠️ mk3-tui source not found in 4runr-os package.\n');
2622
+ process.stderr.write(' Please reinstall: npm install -g 4runr-os@latest\n\n');
2669
2623
  process.exit(1);
2670
2624
  }
2671
2625
  }
2672
- catch (installError) {
2673
- process.stderr.write('\n[ERROR] Auto-install failed. Please install manually:\n');
2674
- process.stderr.write(' npm install -g 4runr-os-mk3\n');
2675
- process.stderr.write('Then run: 4r\n\n');
2676
- // Check if Rust might help (for building from source)
2677
- const { isRustInstalled, getRustInstallCommand } = await import('./rust-check.js');
2678
- if (!isRustInstalled()) {
2679
- process.stderr.write('\n💡 Alternative: Build from source (requires Rust):\n');
2626
+ catch (buildError) {
2627
+ const errorMsg = buildError?.message || String(buildError) || '';
2628
+ const errorOutput = buildError?.buildOutput || buildError?.stdout?.toString() || buildError?.stderr?.toString() || '';
2629
+ const fullError = (errorMsg + ' ' + errorOutput).toLowerCase();
2630
+ if (isWindows && (fullError.includes('link.exe') || fullError.includes('linker') || fullError.includes('msvc'))) {
2631
+ // Windows MSVC linker missing
2632
+ process.stderr.write('\n⚠️ Build failed: MSVC linker not found.\n');
2633
+ process.stderr.write(' Rust is installed, but Windows needs Visual Studio Build Tools.\n\n');
2634
+ process.stderr.write(' Option 1: Install Visual Studio Build Tools (Recommended)\n');
2635
+ process.stderr.write(' 1. Download: https://visualstudio.microsoft.com/downloads/\n');
2636
+ process.stderr.write(' 2. Install "Build Tools for Visual Studio"\n');
2637
+ process.stderr.write(' 3. Select "Desktop development with C++" workload\n');
2638
+ process.stderr.write(' 4. Restart terminal and run "4r" again\n\n');
2639
+ process.stderr.write(' Option 2: Use GNU toolchain (Alternative)\n');
2640
+ process.stderr.write(' 1. Run: rustup toolchain install stable-x86_64-pc-windows-gnu\n');
2641
+ process.stderr.write(' 2. Run: rustup default stable-x86_64-pc-windows-gnu\n');
2642
+ process.stderr.write(' 3. Run "4r" again\n\n');
2643
+ process.stderr.write(' Option 3: Use WSL (Windows Subsystem for Linux)\n');
2644
+ process.stderr.write(' 1. Install WSL: wsl --install\n');
2645
+ process.stderr.write(' 2. In WSL: npm install -g 4runr-os\n');
2646
+ process.stderr.write(' 3. In WSL: 4r\n\n');
2647
+ }
2648
+ else {
2649
+ // Generic build error
2650
+ process.stderr.write('\n⚠️ Build failed. Please ensure Rust is properly installed.\n');
2680
2651
  process.stderr.write(` Install Rust: ${getRustInstallCommand()}\n`);
2681
- process.stderr.write(' Then build: git clone https://github.com/KyanBergeron4Runr/4Runr-AI-Agent-OS.git\n');
2682
- process.stderr.write(' cd 4Runr-AI-Agent-OS/apps/mk3-tui && cargo build --release\n\n');
2652
+ process.stderr.write(' Then run "4r" again.\n\n');
2653
+ if (fullError) {
2654
+ process.stderr.write(' Error details:\n');
2655
+ process.stderr.write(` ${fullError.substring(0, 500)}\n\n`);
2656
+ }
2683
2657
  }
2684
2658
  process.exit(1);
2685
2659
  }
2686
2660
  }
2661
+ else {
2662
+ process.stderr.write('\n💡 To build mk3-tui, you need Rust installed.\n');
2663
+ process.stderr.write(` Install Rust: ${getRustInstallCommand()}\n`);
2664
+ process.stderr.write(' Then run "4r" again - it will build automatically.\n\n');
2665
+ }
2687
2666
  if (!binaryPath) {
2688
2667
  process.exit(1);
2689
2668
  }