Compare commits
3 Commits
4a6878b77b
...
dev
453
Install-Linux.sh
453
Install-Linux.sh
@@ -1,9 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
# NomadArch Installer for Linux
|
||||
# Version: 0.6.0 - Robust Edition
|
||||
# Version: 0.6.1 - Universal Edition
|
||||
|
||||
# Exit on error, but handle gracefully
|
||||
# Exit on error but provide helpful messages
|
||||
set -u
|
||||
|
||||
# Colors
|
||||
@@ -31,19 +31,19 @@ log() {
|
||||
|
||||
print_header() {
|
||||
echo ""
|
||||
echo -e "${CYAN}╔═══════════════════════════════════════════════════════════════╗${NC}"
|
||||
echo -e "${CYAN}║${NC} ${BOLD}NomadArch Installer for Linux${NC} ${CYAN}║${NC}"
|
||||
echo -e "${CYAN}║${NC} Version: 0.6.0 - Robust Edition ${CYAN}║${NC}"
|
||||
echo -e "${CYAN}╚═══════════════════════════════════════════════════════════════╝${NC}"
|
||||
echo -e "${CYAN}==============================================================${NC}"
|
||||
echo -e "${CYAN}|${NC} ${BOLD}NomadArch Installer for Linux${NC} ${CYAN}|${NC}"
|
||||
echo -e "${CYAN}|${NC} Version: 0.6.1 - Universal Edition ${CYAN}|${NC}"
|
||||
echo -e "${CYAN}==============================================================${NC}"
|
||||
echo ""
|
||||
}
|
||||
|
||||
print_header
|
||||
log "========== Installer started =========="
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# ---------------------------------------------------------------
|
||||
# STEP 1: OS and Architecture Detection
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# ---------------------------------------------------------------
|
||||
echo "[STEP 1/8] Detecting System..."
|
||||
|
||||
OS_TYPE=$(uname -s)
|
||||
@@ -52,41 +52,15 @@ log "OS: $OS_TYPE, Arch: $ARCH_TYPE"
|
||||
|
||||
if [[ "$OS_TYPE" != "Linux" ]]; then
|
||||
echo -e "${RED}[ERROR]${NC} This installer is for Linux. Current OS: $OS_TYPE"
|
||||
echo " Use Install-Mac.sh for macOS or Install-Windows.bat for Windows."
|
||||
log "ERROR: Not Linux ($OS_TYPE)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$ARCH_TYPE" in
|
||||
x86_64) ARCH="x64" ;;
|
||||
aarch64) ARCH="arm64" ;;
|
||||
armv7l) ARCH="arm" ;;
|
||||
*)
|
||||
echo -e "${YELLOW}[WARN]${NC} Unusual architecture: $ARCH_TYPE (proceeding anyway)"
|
||||
ARCH="$ARCH_TYPE"
|
||||
((WARNINGS++)) || true
|
||||
;;
|
||||
esac
|
||||
echo -e "${GREEN}[OK]${NC} OS: Linux ($ARCH_TYPE)"
|
||||
|
||||
echo -e "${GREEN}[OK]${NC} OS: Linux"
|
||||
echo -e "${GREEN}[OK]${NC} Architecture: $ARCH_TYPE ($ARCH)"
|
||||
|
||||
# Detect distribution
|
||||
if [[ -f /etc/os-release ]]; then
|
||||
# shellcheck disable=SC1091
|
||||
. /etc/os-release
|
||||
DISTRO="${ID:-unknown}"
|
||||
DISTRO_NAME="${PRETTY_NAME:-$DISTRO}"
|
||||
echo -e "${GREEN}[INFO]${NC} Distribution: $DISTRO_NAME"
|
||||
else
|
||||
DISTRO="unknown"
|
||||
DISTRO_NAME="Unknown Linux"
|
||||
fi
|
||||
log "Distribution: $DISTRO_NAME"
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# ---------------------------------------------------------------
|
||||
# STEP 2: Check Write Permissions
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# ---------------------------------------------------------------
|
||||
echo ""
|
||||
echo "[STEP 2/8] Checking Write Permissions..."
|
||||
|
||||
@@ -98,363 +72,170 @@ if ! touch "$SCRIPT_DIR/.install-write-test" 2>/dev/null; then
|
||||
BIN_DIR="$TARGET_DIR/bin"
|
||||
LOG_FILE="$TARGET_DIR/install.log"
|
||||
mkdir -p "$BIN_DIR"
|
||||
if ! touch "$TARGET_DIR/.install-write-test" 2>/dev/null; then
|
||||
echo -e "${RED}[ERROR]${NC} Cannot write to $TARGET_DIR"
|
||||
log "ERROR: Write permission denied"
|
||||
exit 1
|
||||
fi
|
||||
rm -f "$TARGET_DIR/.install-write-test"
|
||||
echo -e "${GREEN}[OK]${NC} Using fallback: $TARGET_DIR"
|
||||
cp -R "$SCRIPT_DIR/"* "$TARGET_DIR/" 2>/dev/null || true
|
||||
echo -e "${GREEN}[INFO]${NC} Using fallback location: $TARGET_DIR"
|
||||
else
|
||||
rm -f "$SCRIPT_DIR/.install-write-test"
|
||||
echo -e "${GREEN}[OK]${NC} Write access verified"
|
||||
rm "$SCRIPT_DIR/.install-write-test" 2>/dev/null
|
||||
echo -e "${GREEN}[OK]${NC} Write permissions verified"
|
||||
fi
|
||||
log "Install target: $TARGET_DIR"
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# STEP 3: Detect Package Manager and sudo
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# ---------------------------------------------------------------
|
||||
# STEP 3: Check and Install Node.js
|
||||
# ---------------------------------------------------------------
|
||||
echo ""
|
||||
echo "[STEP 3/8] Detecting Package Manager..."
|
||||
|
||||
SUDO=""
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
if command -v sudo >/dev/null 2>&1; then
|
||||
SUDO="sudo"
|
||||
echo -e "${GREEN}[OK]${NC} sudo available (may prompt for password)"
|
||||
else
|
||||
echo -e "${YELLOW}[WARN]${NC} Not root and sudo not found. Package installation may fail."
|
||||
((WARNINGS++)) || true
|
||||
fi
|
||||
else
|
||||
echo -e "${GREEN}[OK]${NC} Running as root"
|
||||
fi
|
||||
|
||||
# Detect package manager
|
||||
PACKAGE_MANAGER=""
|
||||
if command -v apt-get >/dev/null 2>&1; then
|
||||
PACKAGE_MANAGER="apt"
|
||||
echo -e "${GREEN}[OK]${NC} Package manager: apt (Debian/Ubuntu)"
|
||||
elif command -v dnf >/dev/null 2>&1; then
|
||||
PACKAGE_MANAGER="dnf"
|
||||
echo -e "${GREEN}[OK]${NC} Package manager: dnf (Fedora/RHEL)"
|
||||
elif command -v yum >/dev/null 2>&1; then
|
||||
PACKAGE_MANAGER="yum"
|
||||
echo -e "${GREEN}[OK]${NC} Package manager: yum (CentOS/RHEL)"
|
||||
elif command -v pacman >/dev/null 2>&1; then
|
||||
PACKAGE_MANAGER="pacman"
|
||||
echo -e "${GREEN}[OK]${NC} Package manager: pacman (Arch)"
|
||||
elif command -v zypper >/dev/null 2>&1; then
|
||||
PACKAGE_MANAGER="zypper"
|
||||
echo -e "${GREEN}[OK]${NC} Package manager: zypper (openSUSE)"
|
||||
elif command -v apk >/dev/null 2>&1; then
|
||||
PACKAGE_MANAGER="apk"
|
||||
echo -e "${GREEN}[OK]${NC} Package manager: apk (Alpine)"
|
||||
else
|
||||
echo -e "${YELLOW}[WARN]${NC} No recognized package manager found"
|
||||
echo -e "${YELLOW}[INFO]${NC} You may need to install dependencies manually"
|
||||
((WARNINGS++)) || true
|
||||
fi
|
||||
|
||||
# Package installation helper
|
||||
install_packages() {
|
||||
local packages=("$@")
|
||||
if [[ -z "$PACKAGE_MANAGER" ]]; then
|
||||
echo -e "${YELLOW}[WARN]${NC} Cannot install packages: no package manager"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo -e "${BLUE}[INFO]${NC} Installing: ${packages[*]}"
|
||||
case "$PACKAGE_MANAGER" in
|
||||
apt)
|
||||
$SUDO apt-get update -y >/dev/null 2>&1 || true
|
||||
$SUDO apt-get install -y "${packages[@]}"
|
||||
;;
|
||||
dnf)
|
||||
$SUDO dnf install -y "${packages[@]}"
|
||||
;;
|
||||
yum)
|
||||
$SUDO yum install -y "${packages[@]}"
|
||||
;;
|
||||
pacman)
|
||||
$SUDO pacman -Sy --noconfirm "${packages[@]}"
|
||||
;;
|
||||
zypper)
|
||||
$SUDO zypper -n install "${packages[@]}"
|
||||
;;
|
||||
apk)
|
||||
$SUDO apk add --no-cache "${packages[@]}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# STEP 4: Install Node.js
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
echo ""
|
||||
echo "[STEP 4/8] Checking Node.js..."
|
||||
echo "[STEP 3/8] Checking Node.js..."
|
||||
|
||||
NODE_OK=0
|
||||
NPM_OK=0
|
||||
|
||||
if command -v node >/dev/null 2>&1; then
|
||||
NODE_VERSION=$(node --version 2>/dev/null || echo "unknown")
|
||||
if [[ "$NODE_VERSION" != "unknown" ]]; then
|
||||
NODE_MAJOR=$(echo "$NODE_VERSION" | sed 's/v//' | cut -d'.' -f1)
|
||||
echo -e "${GREEN}[OK]${NC} Node.js: $NODE_VERSION"
|
||||
NODE_OK=1
|
||||
|
||||
if [[ $NODE_MAJOR -lt 18 ]]; then
|
||||
echo -e "${YELLOW}[WARN]${NC} Node.js 18+ recommended (current: $NODE_VERSION)"
|
||||
((WARNINGS++)) || true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $NODE_OK -eq 0 ]]; then
|
||||
echo -e "${BLUE}[INFO]${NC} Node.js not found. Attempting installation..."
|
||||
log "Node.js not found, installing"
|
||||
|
||||
INSTALL_SUCCESS=0
|
||||
|
||||
# Try package manager first
|
||||
if [[ -n "$PACKAGE_MANAGER" ]]; then
|
||||
case "$PACKAGE_MANAGER" in
|
||||
apt)
|
||||
# Try NodeSource for newer versions
|
||||
if curl -fsSL https://deb.nodesource.com/setup_20.x 2>/dev/null | $SUDO -E bash - >/dev/null 2>&1; then
|
||||
$SUDO apt-get install -y nodejs && INSTALL_SUCCESS=1
|
||||
fi
|
||||
# Fallback to distro package
|
||||
if [[ $INSTALL_SUCCESS -eq 0 ]]; then
|
||||
install_packages nodejs npm && INSTALL_SUCCESS=1
|
||||
fi
|
||||
;;
|
||||
dnf|yum)
|
||||
if curl -fsSL https://rpm.nodesource.com/setup_20.x 2>/dev/null | $SUDO bash - >/dev/null 2>&1; then
|
||||
$SUDO "$PACKAGE_MANAGER" install -y nodejs && INSTALL_SUCCESS=1
|
||||
fi
|
||||
if [[ $INSTALL_SUCCESS -eq 0 ]]; then
|
||||
install_packages nodejs npm && INSTALL_SUCCESS=1
|
||||
fi
|
||||
;;
|
||||
pacman)
|
||||
install_packages nodejs npm && INSTALL_SUCCESS=1
|
||||
;;
|
||||
zypper)
|
||||
install_packages nodejs18 npm18 && INSTALL_SUCCESS=1
|
||||
if [[ $INSTALL_SUCCESS -eq 0 ]]; then
|
||||
install_packages nodejs npm && INSTALL_SUCCESS=1
|
||||
fi
|
||||
;;
|
||||
apk)
|
||||
install_packages nodejs npm && INSTALL_SUCCESS=1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Try nvm as fallback
|
||||
if [[ $INSTALL_SUCCESS -eq 0 ]] && command -v curl >/dev/null 2>&1; then
|
||||
echo -e "${BLUE}[INFO]${NC} Trying nvm installation..."
|
||||
export NVM_DIR="$HOME/.nvm"
|
||||
if curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh 2>/dev/null | bash >/dev/null 2>&1; then
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
||||
nvm install 20 && INSTALL_SUCCESS=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $INSTALL_SUCCESS -eq 1 ]]; then
|
||||
# Re-check
|
||||
if command -v node >/dev/null 2>&1; then
|
||||
NODE_VERSION=$(node --version)
|
||||
echo -e "${GREEN}[OK]${NC} Node.js installed: $NODE_VERSION"
|
||||
echo -e "${GREEN}[OK]${NC} Node.js found: $NODE_VERSION"
|
||||
NODE_OK=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $NODE_OK -eq 0 ]]; then
|
||||
echo -e "${RED}[ERROR]${NC} Could not install Node.js automatically"
|
||||
echo -e "${YELLOW}[INFO]${NC} Node.js not found. Attempting automatic installation..."
|
||||
|
||||
# Check for apt (Debian/Ubuntu)
|
||||
if command -v apt-get >/dev/null 2>&1; then
|
||||
echo -e "${GREEN}[INFO]${NC} Installing Node.js via apt-get..."
|
||||
sudo apt-get update && sudo apt-get install -y nodejs npm
|
||||
[[ $? -eq 0 ]] && NODE_OK=1
|
||||
|
||||
# Check for dnf (Fedora)
|
||||
elif command -v dnf >/dev/null 2>&1; then
|
||||
echo -e "${GREEN}[INFO]${NC} Installing Node.js via dnf..."
|
||||
sudo dnf install -y nodejs npm
|
||||
[[ $? -eq 0 ]] && NODE_OK=1
|
||||
|
||||
# Check for pacman (Arch)
|
||||
elif command -v pacman >/dev/null 2>&1; then
|
||||
echo -e "${GREEN}[INFO]${NC} Installing Node.js via pacman..."
|
||||
sudo pacman -S --noconfirm nodejs npm
|
||||
[[ $? -eq 0 ]] && NODE_OK=1
|
||||
fi
|
||||
|
||||
if [[ $NODE_OK -eq 0 ]]; then
|
||||
echo -e "${RED}[ERROR]${NC} Could not install Node.js automatically."
|
||||
echo "Please install Node.js manually using your package manager."
|
||||
((ERRORS++))
|
||||
fi
|
||||
fi
|
||||
|
||||
# ---------------------------------------------------------------
|
||||
# STEP 4: Check Git (Optional)
|
||||
# ---------------------------------------------------------------
|
||||
echo ""
|
||||
echo "Please install Node.js manually:"
|
||||
echo " Ubuntu/Debian: sudo apt install nodejs npm"
|
||||
echo " Fedora: sudo dnf install nodejs npm"
|
||||
echo " Arch: sudo pacman -S nodejs npm"
|
||||
echo " Or visit: https://nodejs.org/"
|
||||
echo ""
|
||||
log "ERROR: Node.js installation failed"
|
||||
ERRORS=$((ERRORS+1))
|
||||
|
||||
# Don't exit - let user see summary
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check npm
|
||||
if command -v npm >/dev/null 2>&1; then
|
||||
NPM_VERSION=$(npm --version 2>/dev/null || echo "unknown")
|
||||
if [[ "$NPM_VERSION" != "unknown" ]]; then
|
||||
echo -e "${GREEN}[OK]${NC} npm: $NPM_VERSION"
|
||||
NPM_OK=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $NPM_OK -eq 0 && $NODE_OK -eq 1 ]]; then
|
||||
echo -e "${YELLOW}[WARN]${NC} npm not found, trying to install..."
|
||||
install_packages npm || true
|
||||
if command -v npm >/dev/null 2>&1; then
|
||||
NPM_VERSION=$(npm --version)
|
||||
echo -e "${GREEN}[OK]${NC} npm installed: $NPM_VERSION"
|
||||
NPM_OK=1
|
||||
else
|
||||
echo -e "${RED}[ERROR]${NC} npm not available"
|
||||
ERRORS=$((ERRORS+1))
|
||||
fi
|
||||
fi
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# STEP 5: Check Git and curl (optional)
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
echo ""
|
||||
echo "[STEP 5/8] Checking Optional Dependencies..."
|
||||
echo "[STEP 4/8] Checking Git (optional)..."
|
||||
|
||||
if command -v git >/dev/null 2>&1; then
|
||||
echo -e "${GREEN}[OK]${NC} Git: $(git --version)"
|
||||
GIT_VERSION=$(git --version)
|
||||
echo -e "${GREEN}[OK]${NC} $GIT_VERSION"
|
||||
else
|
||||
echo -e "${YELLOW}[INFO]${NC} Git not found (optional)"
|
||||
((WARNINGS++))
|
||||
fi
|
||||
|
||||
if command -v curl >/dev/null 2>&1; then
|
||||
echo -e "${GREEN}[OK]${NC} curl: available"
|
||||
else
|
||||
echo -e "${YELLOW}[INFO]${NC} curl not found (optional, installing...)"
|
||||
install_packages curl || true
|
||||
fi
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# STEP 6: Install npm Dependencies
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# ---------------------------------------------------------------
|
||||
# STEP 5: Install Dependencies
|
||||
# ---------------------------------------------------------------
|
||||
echo ""
|
||||
echo "[STEP 6/8] Installing Dependencies..."
|
||||
echo "[STEP 5/8] Installing Dependencies..."
|
||||
|
||||
if [[ $NODE_OK -eq 0 || $NPM_OK -eq 0 ]]; then
|
||||
echo -e "${YELLOW}[SKIP]${NC} Skipping npm install (Node.js/npm not available)"
|
||||
else
|
||||
cd "$SCRIPT_DIR"
|
||||
cd "$TARGET_DIR" || exit 1
|
||||
|
||||
if [[ ! -f "package.json" ]]; then
|
||||
echo -e "${RED}[ERROR]${NC} package.json not found in $SCRIPT_DIR"
|
||||
echo "Make sure you extracted the full NomadArch package."
|
||||
log "ERROR: package.json missing"
|
||||
ERRORS=$((ERRORS+1))
|
||||
echo -e "${RED}[ERROR]${NC} package.json not found"
|
||||
((ERRORS++))
|
||||
else
|
||||
echo -e "${BLUE}[INFO]${NC} Running npm install (this may take a few minutes)..."
|
||||
log "Running npm install"
|
||||
|
||||
if npm install --no-audit --no-fund 2>&1; then
|
||||
echo -e "${GREEN}[INFO]${NC} Running npm install..."
|
||||
npm install --no-audit --no-fund || npm install --legacy-peer-deps --no-audit --no-fund
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo -e "${GREEN}[OK]${NC} Dependencies installed"
|
||||
else
|
||||
echo -e "${YELLOW}[WARN]${NC} npm install had issues, trying with legacy peer deps..."
|
||||
if npm install --legacy-peer-deps --no-audit --no-fund 2>&1; then
|
||||
echo -e "${GREEN}[OK]${NC} Dependencies installed (with legacy peer deps)"
|
||||
else
|
||||
echo -e "${RED}[ERROR]${NC} npm install failed"
|
||||
log "ERROR: npm install failed"
|
||||
ERRORS=$((ERRORS+1))
|
||||
fi
|
||||
fi
|
||||
((ERRORS++))
|
||||
fi
|
||||
fi
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# STEP 7: Build UI Assets
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# ---------------------------------------------------------------
|
||||
# STEP 6: OpenCode Setup
|
||||
# ---------------------------------------------------------------
|
||||
echo ""
|
||||
echo "[STEP 6/8] OpenCode Setup..."
|
||||
echo ""
|
||||
echo -e "${CYAN}==============================================================${NC}"
|
||||
echo -e "${CYAN}|${NC} NomadArch supports Binary-Free Mode! ${CYAN}|${NC}"
|
||||
echo -e "${CYAN}|${NC} Using free cloud models: GPT-5 Nano, Grok Code, etc. ${CYAN}|${NC}"
|
||||
echo -e "${CYAN}==============================================================${NC}"
|
||||
echo ""
|
||||
echo "[STEP 7/8] Building UI Assets..."
|
||||
|
||||
if [[ $NODE_OK -eq 0 || $NPM_OK -eq 0 ]]; then
|
||||
echo -e "${YELLOW}[SKIP]${NC} Skipping UI build (Node.js/npm not available)"
|
||||
elif [[ -f "$SCRIPT_DIR/packages/ui/dist/index.html" ]]; then
|
||||
echo -e "${GREEN}[OK]${NC} UI build already exists"
|
||||
echo -e "${GREEN}[OK]${NC} Using Binary-Free Mode (default)"
|
||||
|
||||
# ---------------------------------------------------------------
|
||||
# STEP 7: Build Assets
|
||||
# ---------------------------------------------------------------
|
||||
echo ""
|
||||
echo "[STEP 7/8] Building Assets..."
|
||||
|
||||
if [[ -f "$TARGET_DIR/packages/ui/dist/index.html" ]]; then
|
||||
echo -e "${GREEN}[OK]${NC} UI build exists"
|
||||
else
|
||||
echo -e "${BLUE}[INFO]${NC} Building UI (this may take 1-2 minutes)..."
|
||||
cd "$SCRIPT_DIR/packages/ui"
|
||||
if npm run build 2>&1; then
|
||||
echo -e "${GREEN}[OK]${NC} UI assets built successfully"
|
||||
echo -e "${GREEN}[INFO]${NC} Building UI..."
|
||||
cd "$TARGET_DIR/packages/ui" && npm run build
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo -e "${GREEN}[OK]${NC} UI assets built"
|
||||
else
|
||||
echo -e "${RED}[ERROR]${NC} UI build failed"
|
||||
log "ERROR: UI build failed"
|
||||
ERRORS=$((ERRORS+1))
|
||||
((ERRORS++))
|
||||
fi
|
||||
cd "$SCRIPT_DIR"
|
||||
cd "$TARGET_DIR" || exit 1
|
||||
fi
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# STEP 8: Health Check and Summary
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# ---------------------------------------------------------------
|
||||
# STEP 8: Health Check
|
||||
# ---------------------------------------------------------------
|
||||
echo ""
|
||||
echo "[STEP 8/8] Running Health Check..."
|
||||
|
||||
HEALTH_ERRORS=0
|
||||
HEALTH_OK=1
|
||||
[[ -f "$TARGET_DIR/package.json" ]] || HEALTH_OK=0
|
||||
[[ -d "$TARGET_DIR/packages/ui" ]] || HEALTH_OK=0
|
||||
[[ -d "$TARGET_DIR/packages/server" ]] || HEALTH_OK=0
|
||||
[[ -d "$TARGET_DIR/node_modules" ]] || HEALTH_OK=0
|
||||
|
||||
[[ -f "$SCRIPT_DIR/package.json" ]] || { echo -e "${RED}[FAIL]${NC} package.json missing"; HEALTH_ERRORS=$((HEALTH_ERRORS+1)); }
|
||||
[[ -d "$SCRIPT_DIR/packages/ui" ]] || { echo -e "${RED}[FAIL]${NC} packages/ui missing"; HEALTH_ERRORS=$((HEALTH_ERRORS+1)); }
|
||||
[[ -d "$SCRIPT_DIR/packages/server" ]] || { echo -e "${RED}[FAIL]${NC} packages/server missing"; HEALTH_ERRORS=$((HEALTH_ERRORS+1)); }
|
||||
|
||||
if [[ $NODE_OK -eq 1 && $NPM_OK -eq 1 ]]; then
|
||||
[[ -d "$SCRIPT_DIR/node_modules" ]] || { echo -e "${RED}[FAIL]${NC} node_modules missing"; HEALTH_ERRORS=$((HEALTH_ERRORS+1)); }
|
||||
[[ -f "$SCRIPT_DIR/packages/ui/dist/index.html" ]] || { echo -e "${YELLOW}[WARN]${NC} UI build missing"; ((WARNINGS++)) || true; }
|
||||
fi
|
||||
|
||||
if [[ $HEALTH_ERRORS -eq 0 ]]; then
|
||||
echo -e "${GREEN}[OK]${NC} Health checks passed"
|
||||
if [[ $HEALTH_OK -eq 1 ]]; then
|
||||
echo -e "${GREEN}[OK]${NC} All checks passed"
|
||||
else
|
||||
ERRORS=$((ERRORS+HEALTH_ERRORS))
|
||||
echo -e "${RED}[ERROR]${NC} Health checks failed"
|
||||
((ERRORS++))
|
||||
fi
|
||||
|
||||
# Summary
|
||||
# ---------------------------------------------------------------
|
||||
# SUMMARY
|
||||
# ---------------------------------------------------------------
|
||||
echo ""
|
||||
echo -e "${CYAN}╔═══════════════════════════════════════════════════════════════╗${NC}"
|
||||
echo -e "${CYAN}║${NC} ${BOLD}INSTALLATION SUMMARY${NC} ${CYAN}║${NC}"
|
||||
echo -e "${CYAN}╚═══════════════════════════════════════════════════════════════╝${NC}"
|
||||
echo -e "${CYAN}==============================================================${NC}"
|
||||
echo -e "${CYAN}|${NC} INSTALLATION SUMMARY ${CYAN}|${NC}"
|
||||
echo -e "${CYAN}==============================================================${NC}"
|
||||
echo ""
|
||||
echo " Install Directory: $TARGET_DIR"
|
||||
echo " Architecture: $ARCH ($ARCH_TYPE)"
|
||||
echo " Distribution: $DISTRO_NAME"
|
||||
[[ -n "${NODE_VERSION:-}" ]] && echo " Node.js: $NODE_VERSION"
|
||||
[[ -n "${NPM_VERSION:-}" ]] && echo " npm: $NPM_VERSION"
|
||||
echo " Target: $TARGET_DIR"
|
||||
echo " Mode: Binary-Free Mode"
|
||||
echo " Errors: $ERRORS"
|
||||
echo " Warnings: $WARNINGS"
|
||||
echo " Log File: $LOG_FILE"
|
||||
echo ""
|
||||
|
||||
if [[ $ERRORS -gt 0 ]]; then
|
||||
echo -e "${RED}╔═══════════════════════════════════════════════════════════════╗${NC}"
|
||||
echo -e "${RED}║${NC} ${BOLD}INSTALLATION COMPLETED WITH ERRORS${NC} ${RED}║${NC}"
|
||||
echo -e "${RED}╚═══════════════════════════════════════════════════════════════╝${NC}"
|
||||
echo ""
|
||||
echo "Review the errors above and check: $LOG_FILE"
|
||||
echo ""
|
||||
echo "Common fixes:"
|
||||
echo " 1. Install Node.js: sudo apt install nodejs npm"
|
||||
echo " 2. Run with sudo if permission issues"
|
||||
echo " 3. Check internet connection"
|
||||
echo ""
|
||||
log "Installation FAILED with $ERRORS errors"
|
||||
echo -e "${RED}INSTALLATION FAILED${NC}"
|
||||
echo "Check the log file: $LOG_FILE"
|
||||
exit 1
|
||||
else
|
||||
echo -e "${GREEN}╔═══════════════════════════════════════════════════════════════╗${NC}"
|
||||
echo -e "${GREEN}║${NC} ${BOLD}INSTALLATION SUCCESSFUL!${NC} ${GREEN}║${NC}"
|
||||
echo -e "${GREEN}╚═══════════════════════════════════════════════════════════════╝${NC}"
|
||||
echo -e "${GREEN}INSTALLATION SUCCESSFUL!${NC}"
|
||||
echo ""
|
||||
echo "To start NomadArch, run:"
|
||||
echo " ./Launch-Unix.sh"
|
||||
echo -e " ${BOLD}./Launch-Linux.sh${NC}"
|
||||
echo ""
|
||||
echo "Available Free Models:"
|
||||
echo " - GPT-5 Nano (fast)"
|
||||
echo " - Grok Code (coding)"
|
||||
echo " - GLM-4.7 (general)"
|
||||
echo " - Doubao (creative)"
|
||||
echo ""
|
||||
log "Installation SUCCESSFUL"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
exit $ERRORS
|
||||
|
||||
403
Install-Mac.sh
403
Install-Mac.sh
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# NomadArch Installer for macOS
|
||||
# Version: 0.6.0 - Robust Edition
|
||||
# Version: 0.6.1 - Universal Edition
|
||||
|
||||
# Exit on undefined variables
|
||||
set -u
|
||||
@@ -31,19 +31,19 @@ log() {
|
||||
|
||||
print_header() {
|
||||
echo ""
|
||||
echo -e "${CYAN}╔═══════════════════════════════════════════════════════════════╗${NC}"
|
||||
echo -e "${CYAN}║${NC} ${BOLD}NomadArch Installer for macOS${NC} ${CYAN}║${NC}"
|
||||
echo -e "${CYAN}║${NC} Version: 0.6.0 - Robust Edition ${CYAN}║${NC}"
|
||||
echo -e "${CYAN}╚═══════════════════════════════════════════════════════════════╝${NC}"
|
||||
echo -e "${CYAN}==============================================================${NC}"
|
||||
echo -e "${CYAN}|${NC} ${BOLD}NomadArch Installer for macOS${NC} ${CYAN}|${NC}"
|
||||
echo -e "${CYAN}|${NC} Version: 0.6.1 - Universal Edition ${CYAN}|${NC}"
|
||||
echo -e "${CYAN}==============================================================${NC}"
|
||||
echo ""
|
||||
}
|
||||
|
||||
print_header
|
||||
log "========== Installer started =========="
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# ---------------------------------------------------------------
|
||||
# STEP 1: OS and Architecture Detection
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# ---------------------------------------------------------------
|
||||
echo "[STEP 1/8] Detecting System..."
|
||||
|
||||
OS_TYPE=$(uname -s)
|
||||
@@ -58,8 +58,8 @@ if [[ "$OS_TYPE" != "Darwin" ]]; then
|
||||
fi
|
||||
|
||||
case "$ARCH_TYPE" in
|
||||
arm64) ARCH="arm64" ;;
|
||||
x86_64) ARCH="x64" ;;
|
||||
arm64) ARCH="arm64" ;;
|
||||
*)
|
||||
echo -e "${YELLOW}[WARN]${NC} Unusual architecture: $ARCH_TYPE (proceeding anyway)"
|
||||
ARCH="$ARCH_TYPE"
|
||||
@@ -67,16 +67,12 @@ case "$ARCH_TYPE" in
|
||||
;;
|
||||
esac
|
||||
|
||||
# Get macOS version
|
||||
MACOS_VERSION=$(sw_vers -productVersion 2>/dev/null || echo "unknown")
|
||||
|
||||
echo -e "${GREEN}[OK]${NC} OS: macOS $MACOS_VERSION"
|
||||
echo -e "${GREEN}[OK]${NC} OS: macOS ($OS_TYPE)"
|
||||
echo -e "${GREEN}[OK]${NC} Architecture: $ARCH_TYPE ($ARCH)"
|
||||
log "macOS $MACOS_VERSION, Arch: $ARCH_TYPE"
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# ---------------------------------------------------------------
|
||||
# STEP 2: Check Write Permissions
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# ---------------------------------------------------------------
|
||||
echo ""
|
||||
echo "[STEP 2/8] Checking Write Permissions..."
|
||||
|
||||
@@ -88,326 +84,213 @@ if ! touch "$SCRIPT_DIR/.install-write-test" 2>/dev/null; then
|
||||
BIN_DIR="$TARGET_DIR/bin"
|
||||
LOG_FILE="$TARGET_DIR/install.log"
|
||||
mkdir -p "$BIN_DIR"
|
||||
if ! touch "$TARGET_DIR/.install-write-test" 2>/dev/null; then
|
||||
echo -e "${RED}[ERROR]${NC} Cannot write to $TARGET_DIR"
|
||||
log "ERROR: Write permission denied"
|
||||
exit 1
|
||||
fi
|
||||
rm -f "$TARGET_DIR/.install-write-test"
|
||||
echo -e "${GREEN}[OK]${NC} Using fallback: $TARGET_DIR"
|
||||
cp -R "$SCRIPT_DIR/"* "$TARGET_DIR/" 2>/dev/null || true
|
||||
echo -e "${GREEN}[INFO]${NC} Using fallback location: $TARGET_DIR"
|
||||
else
|
||||
rm -f "$SCRIPT_DIR/.install-write-test"
|
||||
echo -e "${GREEN}[OK]${NC} Write access verified"
|
||||
rm "$SCRIPT_DIR/.install-write-test" 2>/dev/null
|
||||
echo -e "${GREEN}[OK]${NC} Write permissions verified"
|
||||
fi
|
||||
log "Install target: $TARGET_DIR"
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# STEP 3: Check Xcode Command Line Tools
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# ---------------------------------------------------------------
|
||||
# STEP 3: Check and Install Node.js
|
||||
# ---------------------------------------------------------------
|
||||
echo ""
|
||||
echo "[STEP 3/8] Checking Xcode Command Line Tools..."
|
||||
echo "[STEP 3/8] Checking Node.js..."
|
||||
|
||||
if xcode-select -p >/dev/null 2>&1; then
|
||||
echo -e "${GREEN}[OK]${NC} Xcode Command Line Tools installed"
|
||||
else
|
||||
echo -e "${BLUE}[INFO]${NC} Installing Xcode Command Line Tools..."
|
||||
echo -e "${YELLOW}[NOTE]${NC} A dialog may appear - click 'Install' to proceed"
|
||||
xcode-select --install 2>/dev/null || true
|
||||
|
||||
# Wait for installation
|
||||
echo -e "${BLUE}[INFO]${NC} Waiting for Xcode tools installation..."
|
||||
while ! xcode-select -p >/dev/null 2>&1; do
|
||||
sleep 5
|
||||
done
|
||||
echo -e "${GREEN}[OK]${NC} Xcode Command Line Tools installed"
|
||||
fi
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# STEP 4: Check and Install Homebrew + Node.js
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
echo ""
|
||||
echo "[STEP 4/8] Checking Homebrew and Node.js..."
|
||||
|
||||
BREW_OK=0
|
||||
NODE_OK=0
|
||||
NPM_OK=0
|
||||
|
||||
# Check Homebrew
|
||||
if command -v brew >/dev/null 2>&1; then
|
||||
echo -e "${GREEN}[OK]${NC} Homebrew: $(brew --version | head -1)"
|
||||
BREW_OK=1
|
||||
else
|
||||
echo -e "${BLUE}[INFO]${NC} Homebrew not found. Installing..."
|
||||
log "Installing Homebrew"
|
||||
|
||||
if /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; then
|
||||
# Add Homebrew to PATH for Apple Silicon
|
||||
if [[ "$ARCH_TYPE" == "arm64" ]]; then
|
||||
eval "$(/opt/homebrew/bin/brew shellenv)" 2>/dev/null || true
|
||||
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Verify
|
||||
if command -v brew >/dev/null 2>&1; then
|
||||
echo -e "${GREEN}[OK]${NC} Homebrew installed successfully"
|
||||
BREW_OK=1
|
||||
else
|
||||
echo -e "${YELLOW}[WARN]${NC} Homebrew installed but not in PATH"
|
||||
echo -e "${YELLOW}[INFO]${NC} You may need to restart your terminal"
|
||||
((WARNINGS++)) || true
|
||||
|
||||
# Try to find it
|
||||
if [[ -f "/opt/homebrew/bin/brew" ]]; then
|
||||
eval "$(/opt/homebrew/bin/brew shellenv)"
|
||||
BREW_OK=1
|
||||
elif [[ -f "/usr/local/bin/brew" ]]; then
|
||||
eval "$(/usr/local/bin/brew shellenv)"
|
||||
BREW_OK=1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo -e "${RED}[ERROR]${NC} Failed to install Homebrew"
|
||||
log "ERROR: Homebrew installation failed"
|
||||
((WARNINGS++)) || true
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check Node.js
|
||||
if command -v node >/dev/null 2>&1; then
|
||||
NODE_VERSION=$(node --version 2>/dev/null || echo "unknown")
|
||||
if [[ "$NODE_VERSION" != "unknown" ]]; then
|
||||
NODE_MAJOR=$(echo "$NODE_VERSION" | sed 's/v//' | cut -d'.' -f1)
|
||||
echo -e "${GREEN}[OK]${NC} Node.js: $NODE_VERSION"
|
||||
NODE_OK=1
|
||||
|
||||
if [[ $NODE_MAJOR -lt 18 ]]; then
|
||||
echo -e "${YELLOW}[WARN]${NC} Node.js 18+ recommended (current: $NODE_VERSION)"
|
||||
((WARNINGS++)) || true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Install Node.js if needed
|
||||
if [[ $NODE_OK -eq 0 ]]; then
|
||||
echo -e "${BLUE}[INFO]${NC} Node.js not found. Installing..."
|
||||
log "Installing Node.js"
|
||||
|
||||
INSTALL_SUCCESS=0
|
||||
|
||||
# Try Homebrew first
|
||||
if [[ $BREW_OK -eq 1 ]]; then
|
||||
if brew install node 2>&1; then
|
||||
INSTALL_SUCCESS=1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Try nvm as fallback
|
||||
if [[ $INSTALL_SUCCESS -eq 0 ]]; then
|
||||
echo -e "${BLUE}[INFO]${NC} Trying nvm installation..."
|
||||
export NVM_DIR="$HOME/.nvm"
|
||||
if curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh 2>/dev/null | bash >/dev/null 2>&1; then
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
||||
if nvm install 20 2>&1; then
|
||||
INSTALL_SUCCESS=1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Try official pkg installer as last resort
|
||||
if [[ $INSTALL_SUCCESS -eq 0 ]]; then
|
||||
echo -e "${BLUE}[INFO]${NC} Downloading Node.js installer..."
|
||||
NODE_PKG="/tmp/node-installer.pkg"
|
||||
if curl -fsSL "https://nodejs.org/dist/v20.10.0/node-v20.10.0.pkg" -o "$NODE_PKG" 2>/dev/null; then
|
||||
echo -e "${BLUE}[INFO]${NC} Running Node.js installer (may require password)..."
|
||||
sudo installer -pkg "$NODE_PKG" -target / && INSTALL_SUCCESS=1
|
||||
rm -f "$NODE_PKG"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $INSTALL_SUCCESS -eq 1 ]]; then
|
||||
# Verify installation
|
||||
hash -r 2>/dev/null || true
|
||||
if command -v node >/dev/null 2>&1; then
|
||||
NODE_VERSION=$(node --version)
|
||||
echo -e "${GREEN}[OK]${NC} Node.js installed: $NODE_VERSION"
|
||||
echo -e "${GREEN}[OK]${NC} Node.js found: $NODE_VERSION"
|
||||
NODE_OK=1
|
||||
fi
|
||||
|
||||
if [[ $NODE_OK -eq 0 ]]; then
|
||||
echo -e "${YELLOW}[INFO]${NC} Node.js not found. Attempting automatic installation..."
|
||||
log "Node.js not found, attempting install"
|
||||
|
||||
# Check for Homebrew
|
||||
if command -v brew >/dev/null 2>&1; then
|
||||
echo -e "${GREEN}[INFO]${NC} Installing Node.js via Homebrew..."
|
||||
brew install node
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo -e "${GREEN}[OK]${NC} Node.js installed via Homebrew"
|
||||
NODE_OK=1
|
||||
else
|
||||
echo -e "${RED}[ERROR]${NC} Homebrew install failed"
|
||||
fi
|
||||
else
|
||||
echo -e "${YELLOW}[WARN]${NC} Homebrew not found. Trying direct download..."
|
||||
|
||||
# Download macOS installer
|
||||
DOWNLOAD_URL="https://nodejs.org/dist/v20.10.0/node-v20.10.0.pkg"
|
||||
PKG_FILE="$TARGET_DIR/node-installer.pkg"
|
||||
|
||||
echo -e "${GREEN}[INFO]${NC} Downloading Node.js installer..."
|
||||
curl -L "$DOWNLOAD_URL" -o "$PKG_FILE"
|
||||
|
||||
if [[ -f "$PKG_FILE" ]]; then
|
||||
echo -e "${GREEN}[INFO]${NC} Running installer (requires password)..."
|
||||
if sudo installer -pkg "$PKG_FILE" -target /; then
|
||||
echo -e "${GREEN}[OK]${NC} Node.js installed successfully"
|
||||
NODE_OK=1
|
||||
else
|
||||
echo -e "${RED}[ERROR]${NC} Node.js installation failed"
|
||||
fi
|
||||
rm "$PKG_FILE"
|
||||
else
|
||||
echo -e "${RED}[ERROR]${NC} Failed to download Node.js installer"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $NODE_OK -eq 0 ]]; then
|
||||
echo -e "${RED}[ERROR]${NC} Could not install Node.js automatically"
|
||||
echo ""
|
||||
echo "Please install Node.js manually:"
|
||||
echo " 1. Install via Homebrew: brew install node"
|
||||
echo " 2. Or download from: https://nodejs.org/"
|
||||
echo ""
|
||||
echo -e "${RED}[ERROR]${NC} Could not install Node.js automatically."
|
||||
echo "Please install Node.js manually from https://nodejs.org/"
|
||||
echo "and run this installer again."
|
||||
log "ERROR: Node.js installation failed"
|
||||
ERRORS=$((ERRORS+1))
|
||||
((ERRORS++))
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check npm
|
||||
if command -v npm >/dev/null 2>&1; then
|
||||
NPM_VERSION=$(npm --version 2>/dev/null || echo "unknown")
|
||||
if [[ "$NPM_VERSION" != "unknown" ]]; then
|
||||
echo -e "${GREEN}[OK]${NC} npm: $NPM_VERSION"
|
||||
NPM_VERSION=$(npm --version)
|
||||
echo -e "${GREEN}[OK]${NC} npm found: $NPM_VERSION"
|
||||
NPM_OK=1
|
||||
fi
|
||||
else
|
||||
echo -e "${RED}[ERROR]${NC} npm not found (check Node.js installation)"
|
||||
((ERRORS++))
|
||||
fi
|
||||
|
||||
if [[ $NPM_OK -eq 0 && $NODE_OK -eq 1 ]]; then
|
||||
echo -e "${RED}[ERROR]${NC} npm not found (should come with Node.js)"
|
||||
ERRORS=$((ERRORS+1))
|
||||
fi
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# STEP 5: Check Git (optional)
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# ---------------------------------------------------------------
|
||||
# STEP 4: Check Git (Optional)
|
||||
# ---------------------------------------------------------------
|
||||
echo ""
|
||||
echo "[STEP 5/8] Checking Optional Dependencies..."
|
||||
echo "[STEP 4/8] Checking Git (optional)..."
|
||||
|
||||
if command -v git >/dev/null 2>&1; then
|
||||
echo -e "${GREEN}[OK]${NC} Git: $(git --version)"
|
||||
GIT_VERSION=$(git --version)
|
||||
echo -e "${GREEN}[OK]${NC} $GIT_VERSION"
|
||||
else
|
||||
echo -e "${YELLOW}[INFO]${NC} Git not found (optional - installing via Homebrew)"
|
||||
if [[ $BREW_OK -eq 1 ]]; then
|
||||
brew install git 2>/dev/null || true
|
||||
fi
|
||||
echo -e "${YELLOW}[INFO]${NC} Git not found (optional)"
|
||||
((WARNINGS++))
|
||||
fi
|
||||
|
||||
if command -v curl >/dev/null 2>&1; then
|
||||
echo -e "${GREEN}[OK]${NC} curl: available"
|
||||
else
|
||||
echo -e "${RED}[ERROR]${NC} curl not found (required)"
|
||||
ERRORS=$((ERRORS+1))
|
||||
fi
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# STEP 6: Install npm Dependencies
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# ---------------------------------------------------------------
|
||||
# STEP 5: Install Dependencies
|
||||
# ---------------------------------------------------------------
|
||||
echo ""
|
||||
echo "[STEP 6/8] Installing Dependencies..."
|
||||
echo "[STEP 5/8] Installing Dependencies..."
|
||||
|
||||
if [[ $NODE_OK -eq 0 || $NPM_OK -eq 0 ]]; then
|
||||
echo -e "${YELLOW}[SKIP]${NC} Skipping npm install (Node.js/npm not available)"
|
||||
else
|
||||
cd "$SCRIPT_DIR"
|
||||
cd "$TARGET_DIR" || exit 1
|
||||
|
||||
if [[ ! -f "package.json" ]]; then
|
||||
echo -e "${RED}[ERROR]${NC} package.json not found in $SCRIPT_DIR"
|
||||
echo "Make sure you extracted the full NomadArch package."
|
||||
echo -e "${RED}[ERROR]${NC} package.json not found in $TARGET_DIR"
|
||||
log "ERROR: package.json missing"
|
||||
ERRORS=$((ERRORS+1))
|
||||
((ERRORS++))
|
||||
else
|
||||
echo -e "${BLUE}[INFO]${NC} Running npm install (this may take a few minutes)..."
|
||||
echo -e "${GREEN}[INFO]${NC} Running npm install..."
|
||||
log "Running npm install"
|
||||
|
||||
if npm install --no-audit --no-fund 2>&1; then
|
||||
if npm install --no-audit --no-fund; then
|
||||
echo -e "${GREEN}[OK]${NC} Dependencies installed"
|
||||
else
|
||||
echo -e "${YELLOW}[WARN]${NC} npm install had issues, trying with legacy peer deps..."
|
||||
if npm install --legacy-peer-deps --no-audit --no-fund 2>&1; then
|
||||
echo -e "${GREEN}[OK]${NC} Dependencies installed (with legacy peer deps)"
|
||||
echo -e "${YELLOW}[WARN]${NC} npm install issues, trying legacy peer deps..."
|
||||
if npm install --legacy-peer-deps --no-audit --no-fund; then
|
||||
echo -e "${GREEN}[OK]${NC} Dependencies installed (legacy mode)"
|
||||
else
|
||||
echo -e "${RED}[ERROR]${NC} npm install failed"
|
||||
log "ERROR: npm install failed"
|
||||
ERRORS=$((ERRORS+1))
|
||||
fi
|
||||
((ERRORS++))
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# STEP 7: Build UI Assets
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# ---------------------------------------------------------------
|
||||
# STEP 6: OpenCode Setup
|
||||
# ---------------------------------------------------------------
|
||||
echo ""
|
||||
echo "[STEP 6/8] OpenCode Setup..."
|
||||
echo ""
|
||||
echo -e "${CYAN}==============================================================${NC}"
|
||||
echo -e "${CYAN}|${NC} NomadArch supports Binary-Free Mode! ${CYAN}|${NC}"
|
||||
echo -e "${CYAN}|${NC} Using free cloud models: GPT-5 Nano, Grok Code, etc. ${CYAN}|${NC}"
|
||||
echo -e "${CYAN}==============================================================${NC}"
|
||||
echo ""
|
||||
echo "[STEP 7/8] Building UI Assets..."
|
||||
|
||||
if [[ $NODE_OK -eq 0 || $NPM_OK -eq 0 ]]; then
|
||||
echo -e "${YELLOW}[SKIP]${NC} Skipping UI build (Node.js/npm not available)"
|
||||
elif [[ -f "$SCRIPT_DIR/packages/ui/dist/index.html" ]]; then
|
||||
echo -e "${GREEN}[OK]${NC} UI build already exists"
|
||||
echo -e "${GREEN}[OK]${NC} Using Binary-Free Mode (default)"
|
||||
log "Using Binary-Free Mode"
|
||||
|
||||
# ---------------------------------------------------------------
|
||||
# STEP 7: Build Assets
|
||||
# ---------------------------------------------------------------
|
||||
echo ""
|
||||
echo "[STEP 7/8] Building Assets..."
|
||||
|
||||
if [[ -f "$TARGET_DIR/packages/ui/dist/index.html" ]]; then
|
||||
echo -e "${GREEN}[OK]${NC} UI build exists"
|
||||
else
|
||||
echo -e "${BLUE}[INFO]${NC} Building UI (this may take 1-2 minutes)..."
|
||||
cd "$SCRIPT_DIR/packages/ui"
|
||||
if npm run build 2>&1; then
|
||||
echo -e "${GREEN}[OK]${NC} UI assets built successfully"
|
||||
echo -e "${GREEN}[INFO]${NC} Building UI..."
|
||||
cd "$TARGET_DIR/packages/ui" || exit 1
|
||||
if npm run build; then
|
||||
echo -e "${GREEN}[OK]${NC} UI assets built"
|
||||
else
|
||||
echo -e "${RED}[ERROR]${NC} UI build failed"
|
||||
log "ERROR: UI build failed"
|
||||
ERRORS=$((ERRORS+1))
|
||||
((ERRORS++))
|
||||
fi
|
||||
cd "$SCRIPT_DIR"
|
||||
cd "$TARGET_DIR" || exit 1
|
||||
fi
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# STEP 8: Health Check and Summary
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# ---------------------------------------------------------------
|
||||
# STEP 8: Health Check
|
||||
# ---------------------------------------------------------------
|
||||
echo ""
|
||||
echo "[STEP 8/8] Running Health Check..."
|
||||
|
||||
HEALTH_ERRORS=0
|
||||
HEALTH_OK=1
|
||||
|
||||
[[ -f "$SCRIPT_DIR/package.json" ]] || { echo -e "${RED}[FAIL]${NC} package.json missing"; HEALTH_ERRORS=$((HEALTH_ERRORS+1)); }
|
||||
[[ -d "$SCRIPT_DIR/packages/ui" ]] || { echo -e "${RED}[FAIL]${NC} packages/ui missing"; HEALTH_ERRORS=$((HEALTH_ERRORS+1)); }
|
||||
[[ -d "$SCRIPT_DIR/packages/server" ]] || { echo -e "${RED}[FAIL]${NC} packages/server missing"; HEALTH_ERRORS=$((HEALTH_ERRORS+1)); }
|
||||
[[ -f "$TARGET_DIR/package.json" ]] || HEALTH_OK=0
|
||||
[[ -d "$TARGET_DIR/packages/ui" ]] || HEALTH_OK=0
|
||||
[[ -d "$TARGET_DIR/packages/server" ]] || HEALTH_OK=0
|
||||
[[ -d "$TARGET_DIR/node_modules" ]] || HEALTH_OK=0
|
||||
|
||||
if [[ $NODE_OK -eq 1 && $NPM_OK -eq 1 ]]; then
|
||||
[[ -d "$SCRIPT_DIR/node_modules" ]] || { echo -e "${RED}[FAIL]${NC} node_modules missing"; HEALTH_ERRORS=$((HEALTH_ERRORS+1)); }
|
||||
[[ -f "$SCRIPT_DIR/packages/ui/dist/index.html" ]] || { echo -e "${YELLOW}[WARN]${NC} UI build missing"; ((WARNINGS++)) || true; }
|
||||
fi
|
||||
|
||||
if [[ $HEALTH_ERRORS -eq 0 ]]; then
|
||||
echo -e "${GREEN}[OK]${NC} Health checks passed"
|
||||
if [[ $HEALTH_OK -eq 1 ]]; then
|
||||
echo -e "${GREEN}[OK]${NC} All checks passed"
|
||||
else
|
||||
ERRORS=$((ERRORS+HEALTH_ERRORS))
|
||||
echo -e "${RED}[ERROR]${NC} Health checks failed"
|
||||
((ERRORS++))
|
||||
fi
|
||||
|
||||
# Summary
|
||||
# ---------------------------------------------------------------
|
||||
# SUMMARY
|
||||
# ---------------------------------------------------------------
|
||||
echo ""
|
||||
echo -e "${CYAN}╔═══════════════════════════════════════════════════════════════╗${NC}"
|
||||
echo -e "${CYAN}║${NC} ${BOLD}INSTALLATION SUMMARY${NC} ${CYAN}║${NC}"
|
||||
echo -e "${CYAN}╚═══════════════════════════════════════════════════════════════╝${NC}"
|
||||
echo -e "${CYAN}==============================================================${NC}"
|
||||
echo -e "${CYAN}|${NC} INSTALLATION SUMMARY ${CYAN}|${NC}"
|
||||
echo -e "${CYAN}==============================================================${NC}"
|
||||
echo ""
|
||||
echo " Install Directory: $TARGET_DIR"
|
||||
echo " Architecture: $ARCH ($ARCH_TYPE)"
|
||||
echo " macOS Version: $MACOS_VERSION"
|
||||
[[ -n "${NODE_VERSION:-}" ]] && echo " Node.js: $NODE_VERSION"
|
||||
[[ -n "${NPM_VERSION:-}" ]] && echo " npm: $NPM_VERSION"
|
||||
echo " Target: $TARGET_DIR"
|
||||
echo " Mode: Binary-Free Mode"
|
||||
echo " Errors: $ERRORS"
|
||||
echo " Warnings: $WARNINGS"
|
||||
echo " Log File: $LOG_FILE"
|
||||
echo ""
|
||||
|
||||
if [[ $ERRORS -gt 0 ]]; then
|
||||
echo -e "${RED}╔═══════════════════════════════════════════════════════════════╗${NC}"
|
||||
echo -e "${RED}║${NC} ${BOLD}INSTALLATION COMPLETED WITH ERRORS${NC} ${RED}║${NC}"
|
||||
echo -e "${RED}╚═══════════════════════════════════════════════════════════════╝${NC}"
|
||||
echo ""
|
||||
echo "Review the errors above and check: $LOG_FILE"
|
||||
echo ""
|
||||
echo "Common fixes:"
|
||||
echo " 1. Install Homebrew: /bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\""
|
||||
echo " 2. Install Node.js: brew install node"
|
||||
echo " 3. Restart terminal after Homebrew installation"
|
||||
echo ""
|
||||
log "Installation FAILED with $ERRORS errors"
|
||||
echo -e "${RED}==============================================================${NC}"
|
||||
echo -e "${RED} INSTALLATION FAILED${NC}"
|
||||
echo -e "${RED}==============================================================${NC}"
|
||||
echo "Check the log file: $LOG_FILE"
|
||||
exit 1
|
||||
else
|
||||
echo -e "${GREEN}╔═══════════════════════════════════════════════════════════════╗${NC}"
|
||||
echo -e "${GREEN}║${NC} ${BOLD}INSTALLATION SUCCESSFUL!${NC} ${GREEN}║${NC}"
|
||||
echo -e "${GREEN}╚═══════════════════════════════════════════════════════════════╝${NC}"
|
||||
echo -e "${GREEN}==============================================================${NC}"
|
||||
echo -e "${GREEN} INSTALLATION SUCCESSFUL!${NC}"
|
||||
echo -e "${GREEN}==============================================================${NC}"
|
||||
echo ""
|
||||
echo "To start NomadArch, run:"
|
||||
echo " ./Launch-Unix.sh"
|
||||
echo -e " ${BOLD}./Launch-Mac.sh${NC}"
|
||||
echo ""
|
||||
echo "Available Free Models:"
|
||||
echo " - GPT-5 Nano (fast)"
|
||||
echo " - Grok Code (coding)"
|
||||
echo " - GLM-4.7 (general)"
|
||||
echo " - Doubao (creative)"
|
||||
echo ""
|
||||
log "Installation SUCCESSFUL"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
exit $ERRORS
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
@echo off
|
||||
chcp 65001 >nul 2>&1
|
||||
REM NomadArch Windows Installer - ASCII Safe Version
|
||||
REM This installer uses only ASCII characters for maximum compatibility
|
||||
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
title NomadArch Installer - Windows
|
||||
|
||||
echo.
|
||||
echo ╔═══════════════════════════════════════════════════════════════╗
|
||||
echo ║ NomadArch Installer for Windows ║
|
||||
echo ║ Version: 0.6.0 - Robust Edition ║
|
||||
echo ╚═══════════════════════════════════════════════════════════════╝
|
||||
echo ===============================================================
|
||||
echo NomadArch Installer for Windows
|
||||
echo Version: 0.6.1 - Universal Edition
|
||||
echo ===============================================================
|
||||
echo.
|
||||
|
||||
set SCRIPT_DIR=%~dp0
|
||||
@@ -25,9 +27,9 @@ set NODE_INSTALLED_NOW=0
|
||||
|
||||
echo [%date% %time%] ========== Installer started ========== >> "%LOG_FILE%"
|
||||
|
||||
REM ═══════════════════════════════════════════════════════════════
|
||||
REM ---------------------------------------------------------------
|
||||
REM STEP 1: OS and Architecture Detection
|
||||
REM ═══════════════════════════════════════════════════════════════
|
||||
REM ---------------------------------------------------------------
|
||||
echo [STEP 1/8] Detecting System...
|
||||
|
||||
for /f "tokens=2 delims==" %%a in ('wmic os get osarchitecture /value 2^>nul ^| find "="') do set ARCH_RAW=%%a
|
||||
@@ -45,9 +47,9 @@ echo [OK] Windows Version: !WIN_VER!
|
||||
echo [OK] Architecture: !ARCH!
|
||||
echo [%date% %time%] OS: Windows !WIN_VER!, Arch: !ARCH! >> "%LOG_FILE%"
|
||||
|
||||
REM ═══════════════════════════════════════════════════════════════
|
||||
REM ---------------------------------------------------------------
|
||||
REM STEP 2: Check Write Permissions
|
||||
REM ═══════════════════════════════════════════════════════════════
|
||||
REM ---------------------------------------------------------------
|
||||
echo.
|
||||
echo [STEP 2/8] Checking Write Permissions...
|
||||
|
||||
@@ -72,9 +74,9 @@ if !ERRORLEVEL! neq 0 (
|
||||
)
|
||||
echo [%date% %time%] Install target: %TARGET_DIR% >> "%LOG_FILE%"
|
||||
|
||||
REM ═══════════════════════════════════════════════════════════════
|
||||
REM ---------------------------------------------------------------
|
||||
REM STEP 3: Check and Install Node.js
|
||||
REM ═══════════════════════════════════════════════════════════════
|
||||
REM ---------------------------------------------------------------
|
||||
echo.
|
||||
echo [STEP 3/8] Checking Node.js...
|
||||
|
||||
@@ -98,7 +100,7 @@ if !NODE_OK! equ 0 (
|
||||
where winget >nul 2>&1
|
||||
if !ERRORLEVEL! equ 0 (
|
||||
echo [INFO] Installing Node.js via winget...
|
||||
winget install -e --id OpenJS.NodeJS.LTS --accept-source-agreements --accept-package-agreements --silent
|
||||
winget install -e --id OpenJS.NodeJS.LTS --accept-source-agreements --accept-package-agreements --silent 2>nul
|
||||
if !ERRORLEVEL! equ 0 (
|
||||
set NODE_INSTALLED_NOW=1
|
||||
echo [OK] Node.js installed via winget
|
||||
@@ -112,7 +114,7 @@ if !NODE_OK! equ 0 (
|
||||
where choco >nul 2>&1
|
||||
if !ERRORLEVEL! equ 0 (
|
||||
echo [INFO] Installing Node.js via Chocolatey...
|
||||
choco install nodejs-lts -y
|
||||
choco install nodejs-lts -y 2>nul
|
||||
if !ERRORLEVEL! equ 0 (
|
||||
set NODE_INSTALLED_NOW=1
|
||||
echo [OK] Node.js installed via Chocolatey
|
||||
@@ -125,17 +127,12 @@ if !NODE_OK! equ 0 (
|
||||
echo [INFO] Downloading Node.js installer directly...
|
||||
set NODE_INSTALLER=%TEMP_DIR%\node-installer.msi
|
||||
|
||||
REM Download using PowerShell
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
|
||||
"$ProgressPreference = 'SilentlyContinue'; " ^
|
||||
"try { " ^
|
||||
" Invoke-WebRequest -Uri 'https://nodejs.org/dist/v20.10.0/node-v20.10.0-x64.msi' -OutFile '%TEMP_DIR%\node-installer.msi' -UseBasicParsing; " ^
|
||||
" exit 0 " ^
|
||||
"} catch { exit 1 }"
|
||||
REM Download using PowerShell with proper error handling
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -Command "$ProgressPreference = 'SilentlyContinue'; try { Invoke-WebRequest -Uri 'https://nodejs.org/dist/v20.10.0/node-v20.10.0-x64.msi' -OutFile '%TEMP_DIR%\node-installer.msi' -UseBasicParsing; exit 0 } catch { exit 1 }" 2>nul
|
||||
|
||||
if exist "%TEMP_DIR%\node-installer.msi" (
|
||||
echo [INFO] Running Node.js installer...
|
||||
msiexec /i "%TEMP_DIR%\node-installer.msi" /qn /norestart
|
||||
msiexec /i "%TEMP_DIR%\node-installer.msi" /qn /norestart 2>nul
|
||||
if !ERRORLEVEL! equ 0 (
|
||||
set NODE_INSTALLED_NOW=1
|
||||
echo [OK] Node.js installed successfully
|
||||
@@ -150,11 +147,11 @@ if !NODE_OK! equ 0 (
|
||||
|
||||
if !NODE_INSTALLED_NOW! equ 1 (
|
||||
echo.
|
||||
echo ╔═══════════════════════════════════════════════════════════════╗
|
||||
echo ║ IMPORTANT: Node.js was just installed! ║
|
||||
echo ║ Please CLOSE this window and run Install-Windows.bat again. ║
|
||||
echo ║ This is required for the PATH to update. ║
|
||||
echo ╚═══════════════════════════════════════════════════════════════╝
|
||||
echo ===============================================================
|
||||
echo IMPORTANT: Node.js was just installed!
|
||||
echo Please CLOSE this window and run Install-Windows.bat again.
|
||||
echo This is required for the PATH to update.
|
||||
echo ===============================================================
|
||||
echo.
|
||||
echo [%date% %time%] Node.js installed, restart required >> "%LOG_FILE%"
|
||||
pause
|
||||
@@ -191,9 +188,9 @@ if !NPM_OK! equ 0 (
|
||||
goto :SUMMARY
|
||||
)
|
||||
|
||||
REM ═══════════════════════════════════════════════════════════════
|
||||
REM ---------------------------------------------------------------
|
||||
REM STEP 4: Check Git (optional)
|
||||
REM ═══════════════════════════════════════════════════════════════
|
||||
REM ---------------------------------------------------------------
|
||||
echo.
|
||||
echo [STEP 4/8] Checking Git (optional)...
|
||||
|
||||
@@ -206,9 +203,9 @@ if !ERRORLEVEL! equ 0 (
|
||||
set /a WARNINGS+=1
|
||||
)
|
||||
|
||||
REM ═══════════════════════════════════════════════════════════════
|
||||
REM ---------------------------------------------------------------
|
||||
REM STEP 5: Install npm Dependencies
|
||||
REM ═══════════════════════════════════════════════════════════════
|
||||
REM ---------------------------------------------------------------
|
||||
echo.
|
||||
echo [STEP 5/8] Installing Dependencies...
|
||||
|
||||
@@ -238,26 +235,26 @@ if !ERRORLEVEL! neq 0 (
|
||||
)
|
||||
echo [OK] Dependencies installed
|
||||
|
||||
REM ═══════════════════════════════════════════════════════════════
|
||||
REM ---------------------------------------------------------------
|
||||
REM STEP 6: OpenCode Binary (OPTIONAL)
|
||||
REM ═══════════════════════════════════════════════════════════════
|
||||
REM ---------------------------------------------------------------
|
||||
echo.
|
||||
echo [STEP 6/8] OpenCode Binary Setup...
|
||||
echo.
|
||||
echo ╔═══════════════════════════════════════════════════════════════╗
|
||||
echo ║ NomadArch supports Binary-Free Mode! ║
|
||||
echo ║ You can skip the OpenCode binary and use free cloud models: ║
|
||||
echo ║ - GPT-5 Nano, Grok Code, GLM-4.7, Doubao, and more ║
|
||||
echo ╚═══════════════════════════════════════════════════════════════╝
|
||||
echo ===============================================================
|
||||
echo NomadArch supports Binary-Free Mode!
|
||||
echo You can skip the OpenCode binary and use free cloud models:
|
||||
echo - GPT-5 Nano, Grok Code, GLM-4.7, Doubao, and more
|
||||
echo ===============================================================
|
||||
echo.
|
||||
|
||||
set SKIP_OPENCODE=1
|
||||
echo [OK] Using Binary-Free Mode (default)
|
||||
echo [%date% %time%] Using Binary-Free Mode >> "%LOG_FILE%"
|
||||
|
||||
REM ═══════════════════════════════════════════════════════════════
|
||||
REM ---------------------------------------------------------------
|
||||
REM STEP 7: Build UI Assets
|
||||
REM ═══════════════════════════════════════════════════════════════
|
||||
REM ---------------------------------------------------------------
|
||||
echo.
|
||||
echo [STEP 7/8] Building UI Assets...
|
||||
|
||||
@@ -278,9 +275,9 @@ if exist "%SCRIPT_DIR%\packages\ui\dist\index.html" (
|
||||
echo [OK] UI assets built successfully
|
||||
)
|
||||
|
||||
REM ═══════════════════════════════════════════════════════════════
|
||||
REM ---------------------------------------------------------------
|
||||
REM STEP 8: Health Check and Summary
|
||||
REM ═══════════════════════════════════════════════════════════════
|
||||
REM ---------------------------------------------------------------
|
||||
echo.
|
||||
echo [STEP 8/8] Running Health Check...
|
||||
|
||||
@@ -320,9 +317,9 @@ if !HEALTH_OK! equ 1 (
|
||||
|
||||
:SUMMARY
|
||||
echo.
|
||||
echo ╔═══════════════════════════════════════════════════════════════╗
|
||||
echo ║ INSTALLATION SUMMARY ║
|
||||
echo ╚═══════════════════════════════════════════════════════════════╝
|
||||
echo ===============================================================
|
||||
echo INSTALLATION SUMMARY
|
||||
echo ===============================================================
|
||||
echo.
|
||||
echo Install Directory: %TARGET_DIR%
|
||||
echo Architecture: !ARCH!
|
||||
@@ -335,9 +332,9 @@ echo Log File: %LOG_FILE%
|
||||
echo.
|
||||
|
||||
if !ERRORS! gtr 0 (
|
||||
echo ╔═══════════════════════════════════════════════════════════════╗
|
||||
echo ║ INSTALLATION FAILED ║
|
||||
echo ╚═══════════════════════════════════════════════════════════════╝
|
||||
echo ===============================================================
|
||||
echo INSTALLATION FAILED
|
||||
echo ===============================================================
|
||||
echo.
|
||||
echo Review the errors above and check the log file: %LOG_FILE%
|
||||
echo.
|
||||
@@ -349,9 +346,9 @@ if !ERRORS! gtr 0 (
|
||||
echo.
|
||||
echo [%date% %time%] Installation FAILED with !ERRORS! errors >> "%LOG_FILE%"
|
||||
) else (
|
||||
echo ╔═══════════════════════════════════════════════════════════════╗
|
||||
echo ║ INSTALLATION SUCCESSFUL! ║
|
||||
echo ╚═══════════════════════════════════════════════════════════════╝
|
||||
echo ===============================================================
|
||||
echo INSTALLATION SUCCESSFUL!
|
||||
echo ===============================================================
|
||||
echo.
|
||||
echo To start NomadArch, run:
|
||||
echo Launch-Windows.bat
|
||||
|
||||
@@ -287,7 +287,8 @@ export function verifyPassword(userId: string, password: string): boolean {
|
||||
}
|
||||
const computed = hashPassword(password, user.salt)
|
||||
const matches = computed === user.passwordHash
|
||||
console.log("[verifyPassword] userId:", userId, "computed:", computed, "stored:", user.passwordHash, "matches:", matches)
|
||||
console.log("[verifyPassword] userId:", userId, "password:", JSON.stringify(password), "len:", password.length)
|
||||
console.log("[verifyPassword] computed:", computed, "stored:", user.passwordHash, "matches:", matches)
|
||||
return matches
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import { addToTaskQueue, getSoloState, setActiveTaskId, toggleAutonomous, toggle
|
||||
import { getLogger } from "@/lib/logger";
|
||||
import { clearCompactionSuggestion, getCompactionSuggestion } from "@/stores/session-compaction";
|
||||
import { emitSessionSidebarRequest } from "@/lib/session-sidebar-events";
|
||||
import { detectAgentWorkingState, getAgentStatusMessage } from "@/lib/agent-status-detection";
|
||||
import {
|
||||
Command,
|
||||
Plus,
|
||||
@@ -216,7 +217,36 @@ export default function MultiTaskChat(props: MultiTaskChatProps) {
|
||||
|
||||
const store = messageStore();
|
||||
const lastMsg = store.getMessage(ids[ids.length - 1]);
|
||||
return lastMsg?.role === "assistant" && (lastMsg.status === "streaming" || lastMsg.status === "sending");
|
||||
|
||||
// Basic check: streaming or sending status
|
||||
if (lastMsg?.role === "assistant" && (lastMsg.status === "streaming" || lastMsg.status === "sending")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Enhanced check: semantic detection for "standby", "processing" messages
|
||||
// This catches Ollama models that output status messages and pause
|
||||
if (lastMsg?.role === "assistant") {
|
||||
const workingState = detectAgentWorkingState(lastMsg);
|
||||
return workingState.isWorking;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// Get dynamic status message for display
|
||||
const agentStatusMessage = createMemo(() => {
|
||||
const ids = filteredMessageIds();
|
||||
if (ids.length === 0) return "THINKING";
|
||||
|
||||
const store = messageStore();
|
||||
const lastMsg = store.getMessage(ids[ids.length - 1]);
|
||||
|
||||
if (!lastMsg || lastMsg.role !== "assistant") {
|
||||
return "THINKING";
|
||||
}
|
||||
|
||||
const statusMsg = getAgentStatusMessage(lastMsg);
|
||||
return statusMsg?.toUpperCase() || "THINKING";
|
||||
});
|
||||
|
||||
// Auto-scroll during streaming - DISABLED for performance testing
|
||||
@@ -539,7 +569,7 @@ export default function MultiTaskChat(props: MultiTaskChatProps) {
|
||||
<Show when={isAgentThinking()}>
|
||||
<div class="flex items-center space-x-2 px-3 py-1.5 bg-violet-500/15 border border-violet-500/30 rounded-lg animate-pulse shadow-[0_0_20px_rgba(139,92,246,0.2)]">
|
||||
<Sparkles size={12} class="text-violet-400 animate-spin" style={{ "animation-duration": "3s" }} />
|
||||
<span class="text-[10px] font-black text-violet-400 uppercase tracking-tight">Streaming</span>
|
||||
<span class="text-[10px] font-black text-violet-400 uppercase tracking-tight">{agentStatusMessage()}</span>
|
||||
<span class="text-[10px] font-bold text-violet-300">{formatTokenTotal(tokenStats().used)}</span>
|
||||
</div>
|
||||
</Show>
|
||||
@@ -846,7 +876,7 @@ export default function MultiTaskChat(props: MultiTaskChatProps) {
|
||||
<div class="w-1 h-1 bg-indigo-400 rounded-full animate-bounce" style={{ "animation-delay": "150ms" }} />
|
||||
<div class="w-1 h-1 bg-indigo-400 rounded-full animate-bounce" style={{ "animation-delay": "300ms" }} />
|
||||
</div>
|
||||
<span class="text-[9px] font-bold text-indigo-400">{isAgentThinking() ? "THINKING" : "SENDING"}</span>
|
||||
<span class="text-[9px] font-bold text-indigo-400">{isSending() ? "SENDING" : agentStatusMessage()}</span>
|
||||
</div>
|
||||
</Show>
|
||||
</div>
|
||||
|
||||
249
packages/ui/src/lib/agent-status-detection.ts
Normal file
249
packages/ui/src/lib/agent-status-detection.ts
Normal file
@@ -0,0 +1,249 @@
|
||||
/**
|
||||
* Agent Status Detection Module
|
||||
*
|
||||
* Provides intelligent detection of when an agent is still "working" even after
|
||||
* streaming has technically completed. This handles cases where:
|
||||
* 1. Agent outputs "standby", "processing", "working" messages
|
||||
* 2. Agent is in multi-step reasoning mode
|
||||
* 3. Ollama models pause between thinking and output phases
|
||||
*/
|
||||
|
||||
import type { MessageRecord } from "../stores/message-v2/types"
|
||||
|
||||
// Keywords that indicate the agent is still processing
|
||||
const WORKING_KEYWORDS = [
|
||||
"standby",
|
||||
"stand by",
|
||||
"processing",
|
||||
"please wait",
|
||||
"working on",
|
||||
"analyzing",
|
||||
"thinking",
|
||||
"computing",
|
||||
"calculating",
|
||||
"evaluating",
|
||||
"generating",
|
||||
"preparing",
|
||||
"loading",
|
||||
"fetching",
|
||||
"retrieving",
|
||||
"in progress",
|
||||
"one moment",
|
||||
"hold on",
|
||||
"just a sec",
|
||||
"give me a moment",
|
||||
"let me",
|
||||
"i'll",
|
||||
"i will",
|
||||
"checking",
|
||||
"scanning",
|
||||
"searching",
|
||||
"looking",
|
||||
"finding"
|
||||
] as const
|
||||
|
||||
// Keywords that indicate the agent has finished
|
||||
const COMPLETION_KEYWORDS = [
|
||||
"here is",
|
||||
"here's",
|
||||
"here are",
|
||||
"done",
|
||||
"complete",
|
||||
"finished",
|
||||
"result",
|
||||
"solution",
|
||||
"answer",
|
||||
"output",
|
||||
"summary",
|
||||
"conclusion",
|
||||
"final",
|
||||
"successfully",
|
||||
"implemented",
|
||||
"fixed",
|
||||
"resolved",
|
||||
"created",
|
||||
"updated"
|
||||
] as const
|
||||
|
||||
// Patterns that strongly indicate agent is still working
|
||||
const WORKING_PATTERNS = [
|
||||
/stand\s*by/i,
|
||||
/processing\s*(complete\s*)?data/i,
|
||||
/please\s+wait/i,
|
||||
/working\s+on/i,
|
||||
/analyzing/i,
|
||||
/\bwait\b/i,
|
||||
/\bone\s+moment\b/i,
|
||||
/\bhold\s+on\b/i,
|
||||
/\.\.\.\s*$/, // Ends with ellipsis
|
||||
/…\s*$/, // Ends with unicode ellipsis
|
||||
] as const
|
||||
|
||||
/**
|
||||
* Extracts text content from a message's parts
|
||||
*/
|
||||
function extractMessageText(message: MessageRecord): string {
|
||||
const textParts: string[] = []
|
||||
|
||||
for (const partId of message.partIds) {
|
||||
const part = message.parts[partId]
|
||||
if (part?.data) {
|
||||
const data = part.data as Record<string, unknown>
|
||||
if (data.type === "text" && typeof data.text === "string") {
|
||||
textParts.push(data.text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return textParts.join("\n")
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the last N characters of a message for keyword detection
|
||||
*/
|
||||
function getRecentContent(message: MessageRecord, charLimit = 500): string {
|
||||
const fullText = extractMessageText(message)
|
||||
if (fullText.length <= charLimit) {
|
||||
return fullText.toLowerCase()
|
||||
}
|
||||
return fullText.slice(-charLimit).toLowerCase()
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the message content indicates the agent is still working
|
||||
*/
|
||||
export function detectAgentWorkingState(message: MessageRecord | null | undefined): {
|
||||
isWorking: boolean
|
||||
reason?: string
|
||||
confidence: "high" | "medium" | "low"
|
||||
} {
|
||||
if (!message) {
|
||||
return { isWorking: false, confidence: "high" }
|
||||
}
|
||||
|
||||
// If message status is streaming or sending, definitely working
|
||||
if (message.status === "streaming" || message.status === "sending") {
|
||||
return { isWorking: true, reason: "Active streaming", confidence: "high" }
|
||||
}
|
||||
|
||||
// Get recent content to analyze
|
||||
const recentContent = getRecentContent(message)
|
||||
|
||||
if (!recentContent) {
|
||||
return { isWorking: false, confidence: "high" }
|
||||
}
|
||||
|
||||
// Check for working patterns with high confidence
|
||||
for (const pattern of WORKING_PATTERNS) {
|
||||
if (pattern.test(recentContent)) {
|
||||
return {
|
||||
isWorking: true,
|
||||
reason: `Pattern match: ${pattern.source}`,
|
||||
confidence: "high"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if recent content ends with working keywords
|
||||
const lastLine = recentContent.split("\n").pop()?.trim() || ""
|
||||
|
||||
for (const keyword of WORKING_KEYWORDS) {
|
||||
if (lastLine.includes(keyword)) {
|
||||
// Check if there's also a completion keyword nearby
|
||||
const hasCompletionNearby = COMPLETION_KEYWORDS.some(ck =>
|
||||
recentContent.slice(-200).includes(ck)
|
||||
)
|
||||
|
||||
if (!hasCompletionNearby) {
|
||||
return {
|
||||
isWorking: true,
|
||||
reason: `Working keyword: "${keyword}"`,
|
||||
confidence: "medium"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check message age - if very recent and short, might still be working
|
||||
const now = Date.now()
|
||||
const messageAge = now - message.updatedAt
|
||||
const contentLength = extractMessageText(message).length
|
||||
|
||||
// If message was updated very recently (< 2s) and content is short
|
||||
if (messageAge < 2000 && contentLength < 100) {
|
||||
return {
|
||||
isWorking: true,
|
||||
reason: "Recently updated with short content",
|
||||
confidence: "low"
|
||||
}
|
||||
}
|
||||
|
||||
return { isWorking: false, confidence: "high" }
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the last assistant message indicates agent is still conceptually working
|
||||
*/
|
||||
export function isAgentConceptuallyThinking(
|
||||
messages: MessageRecord[],
|
||||
lastAssistantMessage: MessageRecord | null | undefined
|
||||
): boolean {
|
||||
if (!lastAssistantMessage) {
|
||||
return false
|
||||
}
|
||||
|
||||
// Check if message status indicates active work
|
||||
if (lastAssistantMessage.status === "streaming" ||
|
||||
lastAssistantMessage.status === "sending") {
|
||||
return true
|
||||
}
|
||||
|
||||
// Use semantic detection
|
||||
const workingState = detectAgentWorkingState(lastAssistantMessage)
|
||||
return workingState.isWorking
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a user-friendly status message for the current agent state
|
||||
*/
|
||||
export function getAgentStatusMessage(
|
||||
message: MessageRecord | null | undefined
|
||||
): string | null {
|
||||
if (!message) {
|
||||
return null
|
||||
}
|
||||
|
||||
const workingState = detectAgentWorkingState(message)
|
||||
|
||||
if (!workingState.isWorking) {
|
||||
return null
|
||||
}
|
||||
|
||||
if (message.status === "streaming") {
|
||||
return "Streaming..."
|
||||
}
|
||||
|
||||
if (message.status === "sending") {
|
||||
return "Sending..."
|
||||
}
|
||||
|
||||
// Based on reason
|
||||
if (workingState.reason?.includes("standby") ||
|
||||
workingState.reason?.includes("stand by")) {
|
||||
return "Agent processing..."
|
||||
}
|
||||
|
||||
if (workingState.reason?.includes("processing")) {
|
||||
return "Processing..."
|
||||
}
|
||||
|
||||
if (workingState.reason?.includes("analyzing")) {
|
||||
return "Analyzing..."
|
||||
}
|
||||
|
||||
if (workingState.reason?.includes("ellipsis")) {
|
||||
return "Thinking..."
|
||||
}
|
||||
|
||||
return "Working..."
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import type { MessageRecord } from "./message-v2/types"
|
||||
import { sessions } from "./sessions"
|
||||
import { getSessionCompactionState } from "./session-compaction"
|
||||
import { messageStoreBus } from "./message-v2/bus"
|
||||
import { detectAgentWorkingState } from "../lib/agent-status-detection"
|
||||
|
||||
function getSession(instanceId: string, sessionId: string): Session | null {
|
||||
const instanceSessions = sessions().get(instanceId)
|
||||
@@ -159,6 +160,15 @@ export function getSessionStatus(instanceId: string, sessionId: string): Session
|
||||
return "working"
|
||||
}
|
||||
|
||||
// Enhanced: Check if last assistant message content suggests agent is still working
|
||||
// This catches Ollama models that output "standby", "processing" messages and pause
|
||||
if (lastRecord && lastRecord.role === "assistant") {
|
||||
const workingState = detectAgentWorkingState(lastRecord)
|
||||
if (workingState.isWorking && workingState.confidence !== "low") {
|
||||
return "working"
|
||||
}
|
||||
}
|
||||
|
||||
return "idle"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user