diff --git a/.github/workflows/mor-agents-build-linux.yml b/.github/workflows/mor-agents-build-linux.yml index 3d7dcac..09d09cb 100644 --- a/.github/workflows/mor-agents-build-linux.yml +++ b/.github/workflows/mor-agents-build-linux.yml @@ -2,178 +2,178 @@ name: MOR Agents Build Linux on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] workflow_dispatch: jobs: build: runs-on: ubuntu-latest - + steps: - - uses: actions/checkout@v4 - with: - submodules: 'recursive' - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.12' - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - pip install pyinstaller - - - name: Build with PyInstaller - run: | - pyinstaller --name="MORagents" --add-data "images/moragents.png:images" main.py - - - name: Create Debian package - run: | - mkdir -p debian/DEBIAN - mkdir -p debian/usr/bin - mkdir -p debian/usr/share/applications - mkdir -p debian/usr/share/icons/hicolor/256x256/apps - cp -r dist/MORagents/* debian/usr/bin/ - cp images/moragents.png debian/usr/share/icons/hicolor/256x256/apps/moragents.png - echo "[Desktop Entry] - Name=MORagents - Exec=/usr/bin/MORagents - Icon=moragents - Type=Application - Categories=Utility;" > debian/usr/share/applications/moragents.desktop - echo "Package: moragents - Version: 1.0 - Section: utils - Priority: optional - Architecture: amd64 - Maintainer: LachsBagel - Description: MORagents application - MORagents is a desktop application for AI agents." > debian/DEBIAN/control - - dpkg-deb --build debian moragents.deb - - - name: Create setup script - run: | - cat << EOF > moragents-setup.sh - #!/bin/bash - set -e - - # Colors for output - RED='\033[0;31m' - GREEN='\033[0;32m' - YELLOW='\033[0;33m' - NC='\033[0m' # No Color - - # Function to check if a command exists - command_exists() { - command -v "$1" >/dev/null 2>&1 - } - - # Function to add current user to docker group - add_user_to_docker_group() { - local current_user=\$(whoami) - if [ "\$current_user" != "root" ]; then - echo -e "\${YELLOW}Adding current user to docker group...${NC}" - sudo usermod -aG docker "\$current_user" - echo -e "\${GREEN}User added to docker group. Please log out and log back in for changes to take effect.${NC}" - else - echo -e "\${YELLOW}Running as root. Skipping user addition to docker group.${NC}" - fi - } - - # Function to wait for Ollama service to be ready - wait_for_ollama() { - echo -e "\${YELLOW}Waiting for Ollama service to be ready...${NC}" - for i in {1..30}; do - if curl -s http://localhost:11434/api/tags >/dev/null; then - echo -e "\${GREEN}Ollama service is ready.${NC}" - return 0 - fi - sleep 2 - done - echo -e "\${RED}Timed out waiting for Ollama service.${NC}" - return 1 - } - - # Function to pull Ollama model with retries - pull_ollama_model() { - local model=\$1 - local max_attempts=3 - local attempt=1 - - while [ \$attempt -le \$max_attempts ]; do - echo -e "\${YELLOW}Pulling Ollama model \$model (Attempt \$attempt)...${NC}" - if ollama pull \$model; then - echo -e "\${GREEN}Successfully pulled \$model.${NC}" - return 0 - fi - echo -e "\${YELLOW}Failed to pull \$model. Retrying...${NC}" - sleep 5 - attempt=\$((attempt + 1)) - done - - echo -e "\${RED}Failed to pull \$model after \$max_attempts attempts.${NC}" - return 1 - } - - # Install curl if not present - if ! command_exists curl; then - echo -e "\${YELLOW}Installing curl...${NC}" - sudo apt-get update - sudo apt-get install -y curl - fi - - # Install Docker if not present - if ! command_exists docker; then - echo -e "\${YELLOW}Installing Docker...${NC}" - curl -fsSL https://get.docker.com -o get-docker.sh - sudo sh get-docker.sh - add_user_to_docker_group - sudo systemctl enable docker - sudo systemctl start docker - else - echo -e "\${GREEN}Docker is already installed.${NC}" - fi - - # Install Ollama - echo -e "\${YELLOW}Installing Ollama...${NC}" - curl -fsSL https://ollama.com/install.sh | sh - - # Start Ollama service - echo -e "\${YELLOW}Starting Ollama service...${NC}" - nohup ollama serve > /dev/null 2>&1 & - - # Wait for Ollama service to be ready - wait_for_ollama - - # Pull Ollama models - echo -e "\${YELLOW}Pulling Ollama models...${NC}" - pull_ollama_model llama3.1 - pull_ollama_model nomic-embed-text - - # Pull necessary Docker images - echo -e "\${YELLOW}Pulling Docker images...${NC}" - sudo docker pull lachsbagel/moragents_dockers-nginx:amd64-0.1.0 - sudo docker pull lachsbagel/moragents_dockers-agents:amd64-0.1.0 - - # Start Docker containers - echo -e "\${YELLOW}Starting Docker containers...${NC}" - sudo docker run -d --name agents -p 8080:5000 --restart always -v /var/lib/agents -v /app/src lachsbagel/moragents_dockers-agents:amd64-0.1.0 - sudo docker run -d --name nginx -p 3333:80 lachsbagel/moragents_dockers-nginx:amd64-0.1.0 - - echo -e "\${GREEN}Setup complete!${NC}" - EOF - - chmod +x moragents-setup.sh - - - name: Upload Debian Package and Setup Script - uses: actions/upload-artifact@v4 - with: - name: MORagentsSetup-Linux - path: | - moragents.deb - moragents-setup.sh \ No newline at end of file + - uses: actions/checkout@v4 + with: + submodules: "recursive" + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install pyinstaller + + - name: Build with PyInstaller + run: | + pyinstaller --name="MORagents" --add-data "images/moragents.png:images" main.py + + - name: Create Debian package + run: | + mkdir -p debian/DEBIAN + mkdir -p debian/usr/bin + mkdir -p debian/usr/share/applications + mkdir -p debian/usr/share/icons/hicolor/256x256/apps + cp -r dist/MORagents/* debian/usr/bin/ + cp images/moragents.png debian/usr/share/icons/hicolor/256x256/apps/moragents.png + echo "[Desktop Entry] + Name=MORagents + Exec=/usr/bin/MORagents + Icon=moragents + Type=Application + Categories=Utility;" > debian/usr/share/applications/moragents.desktop + echo "Package: moragents + Version: 1.0 + Section: utils + Priority: optional + Architecture: amd64 + Maintainer: LachsBagel + Description: MORagents application + MORagents is a desktop application for AI agents." > debian/DEBIAN/control + + dpkg-deb --build debian moragents.deb + + - name: Create setup script + run: | + cat << EOF > moragents-setup.sh + #!/bin/bash + set -e + + # Colors for output + RED='\033[0;31m' + GREEN='\033[0;32m' + YELLOW='\033[0;33m' + NC='\033[0m' # No Color + + # Function to check if a command exists + command_exists() { + command -v "$1" >/dev/null 2>&1 + } + + # Function to add current user to docker group + add_user_to_docker_group() { + local current_user=\$(whoami) + if [ "\$current_user" != "root" ]; then + echo -e "\${YELLOW}Adding current user to docker group...${NC}" + sudo usermod -aG docker "\$current_user" + echo -e "\${GREEN}User added to docker group. Please log out and log back in for changes to take effect.${NC}" + else + echo -e "\${YELLOW}Running as root. Skipping user addition to docker group.${NC}" + fi + } + + # Function to wait for Ollama service to be ready + wait_for_ollama() { + echo -e "\${YELLOW}Waiting for Ollama service to be ready...${NC}" + for i in {1..30}; do + if curl -s http://localhost:11434/api/tags >/dev/null; then + echo -e "\${GREEN}Ollama service is ready.${NC}" + return 0 + fi + sleep 2 + done + echo -e "\${RED}Timed out waiting for Ollama service.${NC}" + return 1 + } + + # Function to pull Ollama model with retries + pull_ollama_model() { + local model=\$1 + local max_attempts=3 + local attempt=1 + + while [ \$attempt -le \$max_attempts ]; do + echo -e "\${YELLOW}Pulling Ollama model \$model (Attempt \$attempt)...${NC}" + if ollama pull \$model; then + echo -e "\${GREEN}Successfully pulled \$model.${NC}" + return 0 + fi + echo -e "\${YELLOW}Failed to pull \$model. Retrying...${NC}" + sleep 5 + attempt=\$((attempt + 1)) + done + + echo -e "\${RED}Failed to pull \$model after \$max_attempts attempts.${NC}" + return 1 + } + + # Install curl if not present + if ! command_exists curl; then + echo -e "\${YELLOW}Installing curl...${NC}" + sudo apt-get update + sudo apt-get install -y curl + fi + + # Install Docker if not present + if ! command_exists docker; then + echo -e "\${YELLOW}Installing Docker...${NC}" + curl -fsSL https://get.docker.com -o get-docker.sh + sudo sh get-docker.sh + add_user_to_docker_group + sudo systemctl enable docker + sudo systemctl start docker + else + echo -e "\${GREEN}Docker is already installed.${NC}" + fi + + # Install Ollama + echo -e "\${YELLOW}Installing Ollama...${NC}" + curl -fsSL https://ollama.com/install.sh | sh + + # Start Ollama service + echo -e "\${YELLOW}Starting Ollama service...${NC}" + nohup ollama serve > /dev/null 2>&1 & + + # Wait for Ollama service to be ready + wait_for_ollama + + # Pull Ollama models + echo -e "\${YELLOW}Pulling Ollama models...${NC}" + pull_ollama_model llama3.2:3b + pull_ollama_model nomic-embed-text + + # Pull necessary Docker images + echo -e "\${YELLOW}Pulling Docker images...${NC}" + sudo docker pull lachsbagel/moragents_dockers-nginx:amd64-0.2.0 + sudo docker pull lachsbagel/moragents_dockers-agents:amd64-0.2.0 + + # Start Docker containers + echo -e "\${YELLOW}Starting Docker containers...${NC}" + sudo docker run -d --name agents -p 8080:5000 --restart always -v /var/lib/agents -v /app/src lachsbagel/moragents_dockers-agents:amd64-0.2.0 + sudo docker run -d --name nginx -p 3333:80 lachsbagel/moragents_dockers-nginx:amd64-0.2.0 + + echo -e "\${GREEN}Setup complete!${NC}" + EOF + + chmod +x moragents-setup.sh + + - name: Upload Debian Package and Setup Script + uses: actions/upload-artifact@v4 + with: + name: MORagentsSetup-Linux + path: | + moragents.deb + moragents-setup.sh diff --git a/.github/workflows/security_scan.yml b/.github/workflows/security_scan.yml new file mode 100644 index 0000000..ab7ebac --- /dev/null +++ b/.github/workflows/security_scan.yml @@ -0,0 +1,46 @@ +name: Security Scan + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + security_scan: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install safety bandit + + - name: Run Safety check + run: safety check -r requirements.txt + continue-on-error: true + + - name: Run Bandit + run: bandit -r . -f custom + continue-on-error: true + + - name: Run Trivy vulnerability scanner in repo mode + uses: aquasecurity/trivy-action@0.20.0 + with: + scan-type: 'fs' + ignore-unfixed: true + format: 'sarif' + output: 'trivy-results.sarif' + severity: 'CRITICAL' + + - name: Upload Trivy scan results to GitHub Security tab + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: 'trivy-results.sarif' diff --git a/build_assets/macOS/preinstall_ollama.sh b/build_assets/macOS/preinstall_ollama.sh index dfcb2e7..a74c1d5 100644 --- a/build_assets/macOS/preinstall_ollama.sh +++ b/build_assets/macOS/preinstall_ollama.sh @@ -7,5 +7,5 @@ chmod +x ollama sudo mv ollama /usr/local/bin/ nohup /usr/local/bin/ollama serve > /dev/null 2>&1 & -/usr/local/bin/ollama pull llama3.1 +/usr/local/bin/ollama pull llama3.2:3b /usr/local/bin/ollama pull nomic-embed-text diff --git a/build_assets/macOS/welcome.html b/build_assets/macOS/welcome.html index 18ca86d..a355874 100644 --- a/build_assets/macOS/welcome.html +++ b/build_assets/macOS/welcome.html @@ -1,44 +1,57 @@ -
- - -Thank you for choosing to install MORagents on your system. This installer will guide you through the process of setting up MORagents and its dependencies.
-The installer will perform the following steps:
-Please note that during the installation process, you may be prompted to enter your system password to authorize the installation of required components.
-Click "Continue" to proceed with the installation.
- + li { + margin-bottom: 10px; + } + + + ++ Thank you for choosing to install MORagents on your system. This installer + will guide you through the process of setting up MORagents and its + dependencies. +
+The installer will perform the following steps:
++ Please note that during the installation process, you may be prompted to + enter your system password to authorize the installation of required + components. +
+Click "Continue" to proceed with the installation.
+