Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
refactor: Simplify install scripts, use pip for uv
trohitg671074c7d0bf
diff --git a/install.sh b/install.shindex 88cc292b..d7c211bc 100644--- a/install.sh+++ b/install.sh@@ -1,343 +1,55 @@#!/usr/bin/env bash# MachinaOS Installer-# Usage: curl -fsSL https://raw.githubusercontent.com/trohitg/MachinaOS/main/install.sh | bash+# Prerequisites: Node.js 20+, Python 3.11+#-# This script installs MachinaOS and its dependencies:-# - Node.js 18+ (if not installed)-# - Python 3.11+ (if not installed)-# - uv (Python package manager)-# - Go 1.21+ (for WhatsApp service)+# Usage: curl -fsSL https://raw.githubusercontent.com/trohitg/MachinaOS/main/install.sh | bashset -e-# Colors-RED='\033[0;31m'-GREEN='\033[0;32m'-YELLOW='\033[1;33m'-BLUE='\033[0;34m'-CYAN='\033[0;36m'-NC='\033[0m' # No Color--# Configuration-REPO_URL="https://github.com/trohitg/MachinaOS.git"-INSTALL_DIR="${MACHINAOS_HOME:-$HOME/.machinaos}"-MIN_NODE_VERSION=18-MIN_PYTHON_VERSION="3.11"-MIN_GO_VERSION="1.21"--# Logging functions-info() { echo -e "${BLUE}[INFO]${NC} $1"; }-success() { echo -e "${GREEN}[OK]${NC} $1"; }-warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }-error() { echo -e "${RED}[ERROR]${NC} $1"; exit 1; }--# Banner-echo -e "${CYAN}"-echo " __ __ _ _ ___ ____ "-echo " | \/ | __ _ ___| |__ (_)_ __ __ _/ _ \/ ___| "-echo " | |\/| |/ _\` |/ __| '_ \| | '_ \ / _\` | | | \___ \\ "-echo " | | | | (_| | (__| | | | | | | | (_| | |_| |___) |"-echo " |_| |_|\__,_|\___|_| |_|_|_| |_|\__,_|\___/|____/ "-echo -e "${NC}"-echo "Open-source workflow automation with AI agents"+echo "Installing MachinaOS..."echo ""-# Detect OS-detect_os() {- case "$(uname -s)" in- Linux*) OS="linux";;- Darwin*) OS="macos";;- MINGW*|MSYS*|CYGWIN*) OS="windows";;- *) error "Unsupported operating system: $(uname -s)";;- esac-- # Detect architecture- case "$(uname -m)" in- x86_64|amd64) ARCH="x64";;- arm64|aarch64) ARCH="arm64";;- *) error "Unsupported architecture: $(uname -m)";;- esac-- info "Detected: $OS ($ARCH)"-}--# Check if command exists-has_cmd() {- command -v "$1" &> /dev/null-}--# Get version number from string-get_version() {- echo "$1" | grep -oE '[0-9]+\.[0-9]+' | head -1-}--# Compare versions (returns 0 if $1 >= $2)-version_gte() {- [ "$(printf '%s\n' "$2" "$1" | sort -V | head -n1)" = "$2" ]-}--# =============================================================================-# Dependency Checks and Installation-# =============================================================================--check_node() {- if has_cmd node; then- NODE_VERSION=$(node --version | sed 's/v//')- NODE_MAJOR=$(echo "$NODE_VERSION" | cut -d. -f1)- if [ "$NODE_MAJOR" -ge "$MIN_NODE_VERSION" ]; then- success "Node.js v$NODE_VERSION"- return 0- else- warn "Node.js v$NODE_VERSION is too old (need v$MIN_NODE_VERSION+)"- fi- fi- return 1-}--install_node() {- info "Installing Node.js..."-- if [ "$OS" = "macos" ]; then- if has_cmd brew; then- brew install node@20- else- error "Please install Homebrew first: https://brew.sh/"- fi- elif [ "$OS" = "linux" ]; then- # Use NodeSource for latest Node.js- if has_cmd curl; then- curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -- sudo apt-get install -y nodejs- else- error "curl is required. Install with: sudo apt install curl"- fi- fi-- check_node || error "Failed to install Node.js"-}--check_python() {- local py_cmd=""-- # Try python3 first, then python- for cmd in python3 python; do- if has_cmd "$cmd"; then- PY_VERSION=$($cmd --version 2>&1 | grep -oE '[0-9]+\.[0-9]+')- if version_gte "$PY_VERSION" "$MIN_PYTHON_VERSION"; then- success "Python $PY_VERSION ($cmd)"- PYTHON_CMD="$cmd"- return 0- fi- fi- done-- warn "Python $MIN_PYTHON_VERSION+ not found"- return 1-}--install_python() {- info "Installing Python..."-- if [ "$OS" = "macos" ]; then- if has_cmd brew; then- brew install [email protected]- else- error "Please install Homebrew first: https://brew.sh/"- fi- elif [ "$OS" = "linux" ]; then- if has_cmd apt; then- sudo apt update- sudo apt install -y python3.12 python3.12-venv python3-pip- elif has_cmd dnf; then- sudo dnf install -y python3.12- elif has_cmd pacman; then- sudo pacman -S --noconfirm python- else- error "Please install Python manually from https://python.org/"- fi- fi-- check_python || error "Failed to install Python"-}--check_uv() {- if has_cmd uv; then- UV_VERSION=$(uv --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')- success "uv $UV_VERSION"- return 0- fi- return 1-}--install_uv() {- info "Installing uv (Python package manager)..."- curl -LsSf https://astral.sh/uv/install.sh | sh-- # Add to PATH for current session- export PATH="$HOME/.local/bin:$PATH"-- check_uv || error "Failed to install uv"-}--check_go() {- if has_cmd go; then- GO_VERSION=$(go version | grep -oE 'go[0-9]+\.[0-9]+' | sed 's/go//')- if version_gte "$GO_VERSION" "$MIN_GO_VERSION"; then- success "Go $GO_VERSION"- return 0- else- warn "Go $GO_VERSION is too old (need $MIN_GO_VERSION+)"- fi- fi- return 1-}+# Check Node.js+if ! command -v node &> /dev/null; then+ echo "Error: Node.js 20+ is required"+ echo " Install from: https://nodejs.org/"+ exit 1+fi+echo " Node.js: $(node --version)"++# Check Python+if command -v python3 &> /dev/null; then+ PY=python3+elif command -v python &> /dev/null; then+ PY=python+else+ echo "Error: Python 3.11+ is required"+ echo " Install from: https://python.org/"+ exit 1+fi+echo " Python: $($PY --version)"++# Ensure pip is available (use ensurepip if missing)+if ! $PY -m pip --version &> /dev/null; then+ echo " Installing pip..."+ $PY -m ensurepip --upgrade+fi++# Install uv via pip if not found+if ! command -v uv &> /dev/null; then+ echo " Installing uv..."+ $PY -m pip install uv+fi+echo " uv: $(uv --version)"-install_go() {- info "Installing Go..."-- if [ "$OS" = "macos" ]; then- if has_cmd brew; then- brew install go- else- error "Please install Homebrew first: https://brew.sh/"- fi- elif [ "$OS" = "linux" ]; then- if has_cmd apt; then- sudo apt update- sudo apt install -y golang-go- elif has_cmd dnf; then- sudo dnf install -y golang- elif has_cmd pacman; then- sudo pacman -S --noconfirm go- else- # Manual install- GO_TAR="go1.21.13.linux-${ARCH}.tar.gz"- curl -LO "https://go.dev/dl/$GO_TAR"- sudo rm -rf /usr/local/go- sudo tar -C /usr/local -xzf "$GO_TAR"- rm "$GO_TAR"- export PATH="$PATH:/usr/local/go/bin"- fi- fi-- check_go || error "Failed to install Go"-}--check_git() {- if has_cmd git; then- GIT_VERSION=$(git --version | grep -oE '[0-9]+\.[0-9]+')- success "Git $GIT_VERSION"- return 0- fi- return 1-}--install_git() {- info "Installing Git..."-- if [ "$OS" = "macos" ]; then- xcode-select --install 2>/dev/null || true- elif [ "$OS" = "linux" ]; then- if has_cmd apt; then- sudo apt update && sudo apt install -y git- elif has_cmd dnf; then- sudo dnf install -y git- elif has_cmd pacman; then- sudo pacman -S --noconfirm git- fi- fi-- check_git || error "Failed to install Git"-}--# =============================================================================-# MachinaOS Installation-# =============================================================================--install_machinaos() {- echo ""- info "Installing MachinaOS to $INSTALL_DIR..."-- # Create install directory- mkdir -p "$INSTALL_DIR"-- # Clone or update repository- if [ -d "$INSTALL_DIR/.git" ]; then- info "Updating existing installation..."- cd "$INSTALL_DIR"- git pull origin main- else- info "Cloning repository..."- git clone "$REPO_URL" "$INSTALL_DIR"- cd "$INSTALL_DIR"- fi-- # Run build- info "Building MachinaOS..."- npm run build-- # Create symlink for global command- info "Creating global command..."-- SYMLINK_DIR="$HOME/.local/bin"- mkdir -p "$SYMLINK_DIR"-- # Remove old symlink if exists- rm -f "$SYMLINK_DIR/machinaos"-- # Create new symlink- ln -s "$INSTALL_DIR/bin/cli.js" "$SYMLINK_DIR/machinaos"- chmod +x "$INSTALL_DIR/bin/cli.js"-- # Check if PATH includes ~/.local/bin- if [[ ":$PATH:" != *":$SYMLINK_DIR:"* ]]; then- warn "Add $SYMLINK_DIR to your PATH:"- echo ""- echo " # Add to ~/.bashrc or ~/.zshrc:"- echo " export PATH=\"\$HOME/.local/bin:\$PATH\""- echo ""- fi-}--# =============================================================================-# Main Installation Flow-# =============================================================================--main() {- detect_os-- echo ""- info "Checking dependencies..."- echo ""-- # Check and install dependencies- check_git || install_git- check_node || install_node- check_python || install_python- check_uv || install_uv- check_go || install_go-- # Install MachinaOS- install_machinaos+echo ""- echo ""- echo -e "${GREEN}============================================${NC}"- echo -e "${GREEN} MachinaOS installed successfully!${NC}"- echo -e "${GREEN}============================================${NC}"- echo ""- echo " Start MachinaOS:"- echo " cd $INSTALL_DIR && npm run start"- echo ""- echo " Or use the global command (after adding to PATH):"- echo " machinaos start"- echo ""- echo " Open in browser:"- echo " http://localhost:3000"- echo ""- echo " Documentation:"- echo " https://github.com/trohitg/MachinaOS"- echo ""-}+# Install machinaos from npm (includes whatsapp-rpc)+npm install -g machinaos-# Run main-main "$@"+echo ""+echo "MachinaOS installed successfully!"+echo ""+echo " Start: machinaos start"+echo " Open: http://localhost:3000"+echo ""diff --git a/scripts/build.js b/scripts/build.jsindex adb04c5b..cb1a2ab5 100644--- a/scripts/build.js+++ b/scripts/build.js@@ -16,10 +16,6 @@ import { fileURLToPath } from 'url';const __dirname = dirname(fileURLToPath(import.meta.url));const ROOT = resolve(__dirname, '..');-// Platform detection-const isWindows = process.platform === 'win32';-const isMac = process.platform === 'darwin';-// Environment detection// - postinstall: npm already installed root deps, skip to avoid infinite loop// - CI: GitHub Actions handles build separately, skip postinstall entirely@@ -61,70 +57,23 @@ function npmInstall(cwd = ROOT) {}// ============================================================================-// Auto-install missing dependencies+// Install dependencies via pip// ============================================================================-function installPython() {- console.log(' Installing Python 3.11+...');- if (isWindows) {- if (runSilent('winget --version')) {- run('winget install Python.Python.3.12 --accept-package-agreements --accept-source-agreements');- } else if (runSilent('choco --version')) {- run('choco install python312 -y');- } else {- console.log(' Error: Please install Python manually from https://python.org/');- console.log(' Or install winget/chocolatey first.');- process.exit(1);- }- } else if (isMac) {- if (runSilent('brew --version')) {- run('brew install [email protected]');- } else {- console.log(' Error: Please install Homebrew first: https://brew.sh/');- process.exit(1);- }- } else {- // Linux package managers- if (runSilent('apk --version')) {- // Alpine Linux- run('apk add --no-cache python3 py3-pip');- } else if (runSilent('apt --version')) {- run('sudo apt update && sudo apt install -y python3.12 python3.12-venv');- } else if (runSilent('dnf --version')) {- run('sudo dnf install -y python3.12');- } else if (runSilent('pacman --version')) {- run('sudo pacman -S --noconfirm python');- } else {- console.log(' Error: Please install Python manually from https://python.org/');- process.exit(1);- }+function ensurePip(pythonCmd) {+ // Check if pip exists, install via ensurepip if missing+ if (!runSilent(`${pythonCmd} -m pip --version`)) {+ console.log(' Installing pip via ensurepip...');+ run(`${pythonCmd} -m ensurepip --upgrade`);}}function installUv(pythonCmd) {- console.log(' Installing uv...');- if (isWindows) {- // Windows: use pip (simple and works)- run(`${pythonCmd} -m pip install uv`);- } else if (isMac) {- // macOS: use pip (no PEP 668 issues with Homebrew Python)- run(`${pythonCmd} -m pip install uv`);- } else if (runSilent('apk --version')) {- // Alpine: use pip with --break-system-packages- run(`${pythonCmd} -m pip install uv --break-system-packages`);- } else {- // Other Linux: try pip first, fall back to curl installer- if (runSilent(`${pythonCmd} -m pip install uv --break-system-packages`)) {- // pip worked- } else {- run('curl -LsSf https://astral.sh/uv/install.sh | sh');- process.env.PATH = `${process.env.HOME}/.local/bin:${process.env.PATH}`;- }- }+ ensurePip(pythonCmd);+ console.log(' Installing uv via pip...');+ run(`${pythonCmd} -m pip install uv`);}-// Go is no longer required - whatsapp-rpc is an npm package with pre-built binaries-// ============================================================================// Check and Install Dependencies// ============================================================================@@ -137,7 +86,7 @@ console.log(` Node.js: ${nodeVersion}`);const npmVersion = getVersion('npm --version');console.log(` npm: ${npmVersion}`);-// Python+// Python (required, user must install)let pyCmd = null;if (runSilent('python --version')) {pyCmd = 'python';@@ -154,13 +103,14 @@ if (pyCmd) {console.log(` ${pyVersion}`);} else {console.log(` ${pyVersion} (too old, need 3.11+)`);- installPython();+ console.log(' Error: Please install Python 3.11+ from https://python.org/');+ process.exit(1);}}} else {- installPython();- pyCmd = runSilent('python --version') ? 'python' : 'python3';- console.log(` ${getVersion(`${pyCmd} --version`)}`);+ console.log(' Error: Python 3.11+ is required.');+ console.log(' Install from: https://python.org/downloads/');+ process.exit(1);}// uv@@ -179,15 +129,6 @@ if (uvVersion) {}}-// Go is optional (whatsapp-rpc uses pre-built binaries)-const goVersionFull = getVersion('go version');-if (goVersionFull) {- const goVersion = goVersionFull.match(/go\d+\.\d+(\.\d+)?/)?.[0] || 'go';- console.log(` Go: ${goVersion} (optional)`);-} else {- console.log(' Go: not installed (optional - whatsapp-rpc uses pre-built binaries)');-}-console.log('\nAll dependencies ready.\n');// ============================================================================diff --git a/scripts/install.js b/scripts/install.jsindex 6102b78c..72457162 100644--- a/scripts/install.js+++ b/scripts/install.js@@ -20,9 +20,6 @@ process.env.MACHINAOS_INSTALLING = 'true';const __dirname = dirname(fileURLToPath(import.meta.url));const ROOT = resolve(__dirname, '..');-const isWindows = process.platform === 'win32';-const isMac = process.platform === 'darwin';-process.env.PYTHONUTF8 = '1';function run(cmd, cwd = ROOT, timeoutMs = 300000) {@@ -72,62 +69,18 @@ function checkUv() {return getVersion('uv --version');}-function installPython() {- console.log('Installing Python 3.11+...');- if (isWindows) {- // choco is pre-installed on GitHub Actions Windows runners- // winget is only on windows-2025, not windows-2022 (windows-latest)- if (runSilent('choco --version')) {- run('choco install python312 -y');- } else if (runSilent('winget --version')) {- run('winget install Python.Python.3.12 --accept-package-agreements --accept-source-agreements --disable-interactivity');- } else {- console.log('ERROR: Cannot auto-install Python. Please install manually:');- console.log(' https://python.org/downloads/');- process.exit(1);- }- } else if (isMac) {- if (runSilent('brew --version')) {- run('brew install [email protected]');- } else {- console.log('ERROR: Homebrew not found. Install it first:');- console.log(' /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"');- process.exit(1);- }- } else {- // Linux - try package managers- if (runSilent('apt-get --version')) {- run('apt-get update && apt-get install -y python3 python3-venv python3-pip curl');- } else if (runSilent('dnf --version')) {- run('dnf install -y python3 python3-pip');- } else if (runSilent('pacman --version')) {- run('pacman -S --noconfirm python python-pip');- } else if (runSilent('apk --version')) {- run('apk add --no-cache python3 py3-pip');- } else {- console.log('ERROR: Cannot auto-install Python. Please install manually:');- console.log(' https://python.org/downloads/');- process.exit(1);- }+function ensurePip(pythonCmd) {+ // Check if pip exists, install via ensurepip if missing+ if (!runSilent(`${pythonCmd} -m pip --version`)) {+ console.log('Installing pip via ensurepip...');+ run(`${pythonCmd} -m ensurepip --upgrade`);}}function installUv(pythonCmd) {- console.log('Installing uv...');- if (isWindows) {- // Use pip on Windows (no PEP 668 issues)- run(`${pythonCmd} -m pip install uv`);- } else if (isMac) {- // Use pip on macOS (no PEP 668 issues with Homebrew Python)- run(`${pythonCmd} -m pip install uv`);- } else if (runSilent('apk --version')) {- // Alpine: use pip (apk doesn't have uv package)- run(`${pythonCmd} -m pip install uv --break-system-packages`);- } else {- // Linux: use official installer (avoids PEP 668 externally-managed-environment)- run('curl -LsSf https://astral.sh/uv/install.sh | sh');- process.env.PATH = `${process.env.HOME}/.local/bin:${process.env.PATH}`;- }+ ensurePip(pythonCmd);+ console.log('Installing uv via pip...');+ run(`${pythonCmd} -m pip install uv`);}// ============================================================================@@ -140,19 +93,14 @@ console.log('');console.log(` Node.js: ${getVersion('node --version')}`);console.log(` npm: ${getVersion('npm --version')}`);-// Check/Install Python+// Check Python (required, user must install)let python = checkPython();if (python) {console.log(` Python: ${python.version}`);} else {- installPython();- python = checkPython();- if (python) {- console.log(` Python: ${python.version}`);- } else {- console.log('ERROR: Python installation failed');- process.exit(1);- }+ console.log('ERROR: Python 3.11+ is required.');+ console.log(' Install from: https://python.org/downloads/');+ process.exit(1);}// Check/Install uv@@ -170,14 +118,6 @@ if (uvVersion) {}}-// Go is optional (whatsapp-rpc uses pre-built binaries via npm)-const goVersion = getVersion('go version');-if (goVersion) {- console.log(` Go: ${goVersion.match(/go\d+\.\d+(\.\d+)?/)?.[0] || 'installed'} (optional)`);-} else {- console.log(' Go: not installed (optional - whatsapp-rpc uses pre-built binaries)');-}-console.log('');console.log('Installing...');console.log('');diff --git a/uninstall.sh b/uninstall.shnew file mode 100644index 00000000..deefc09b--- /dev/null+++ b/uninstall.sh@@ -0,0 +1,21 @@+#!/usr/bin/env bash+# MachinaOS Uninstaller+#+# Usage: curl -fsSL https://raw.githubusercontent.com/trohitg/MachinaOS/main/uninstall.sh | bash++set -e++echo "Uninstalling MachinaOS..."+echo ""++# Uninstall machinaos npm package+if npm list -g machinaos &> /dev/null; then+ npm uninstall -g machinaos+ echo "machinaos removed"+else+ echo "machinaos not installed"+fi++echo ""+echo "Done!"+echo ""