Skip to content

Agent Zero AI framework

The Merge - initial changes

frdeld0ae5e54f728
diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile
new file mode 100644
index 000000000..448171507
--- /dev/null
+++ b/docker/base/Dockerfile
@@ -0,0 +1,31 @@
+# Use the latest slim version of Kali Linux
+FROM kalilinux/kali-rolling
+
+
+# Set locale to en_US.UTF-8 and timezone to UTC
+RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y locales tzdata
+RUN sed -i -e 's/# \(en_US\.UTF-8 .*\)/\1/' /etc/locale.gen && \
+ dpkg-reconfigure --frontend=noninteractive locales && \
+ update-locale LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8
+RUN ln -sf /usr/share/zoneinfo/UTC /etc/localtime
+RUN echo "UTC" > /etc/timezone
+RUN dpkg-reconfigure -f noninteractive tzdata
+ENV LANG=en_US.UTF-8
+ENV LANGUAGE=en_US:en
+ENV LC_ALL=en_US.UTF-8
+ENV TZ=UTC
+
+# Copy contents of the project to /
+COPY ./fs/ /
+
+# install python
+RUN bash /ins/install_python.sh
+
+# install packages software
+RUN bash /ins/install_base_packages.sh
+
+# configure ssh
+RUN bash /ins/configure_ssh.sh
+
+# Keep container running infinitely
+CMD ["tail", "-f", "/dev/null"]
diff --git a/docker/base/build.txt b/docker/base/build.txt
new file mode 100644
index 000000000..6d746a18a
--- /dev/null
+++ b/docker/base/build.txt
@@ -0,0 +1,15 @@
+# local image with smart cache
+docker build -t agent-zero-base:local --build-arg CACHE_DATE=$(date +%Y-%m-%d:%H:%M:%S) .
+
+# local image without cache
+docker build -t agent-zero-base:local --no-cache .
+
+# dockerhub push:
+
+docker login
+
+# with cache
+docker buildx build -t frdel/agent-zero-base:latest --platform linux/amd64,linux/arm64 --push --build-arg CACHE_DATE=$(date +%Y-%m-%d:%H:%M:%S) .
+
+# without cache
+docker buildx build -t frdel/agent-zero-base:latest --platform linux/amd64,linux/arm64 --push --build-arg CACHE_DATE=$(date +%Y-%m-%d:%H:%M:%S) --no-cache .
diff --git a/docker/base/fs/ins/configure_ssh.sh b/docker/base/fs/ins/configure_ssh.sh
new file mode 100644
index 000000000..972531910
--- /dev/null
+++ b/docker/base/fs/ins/configure_ssh.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+# Set up SSH
+mkdir -p /var/run/sshd && \
+ sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
\ No newline at end of file
diff --git a/docker/base/fs/ins/configure_venv.sh b/docker/base/fs/ins/configure_venv.sh
new file mode 100644
index 000000000..d9d07d0ce
--- /dev/null
+++ b/docker/base/fs/ins/configure_venv.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+if [ ! -d /opt/venv ]; then
+ # Create and activate Python virtual environment
+ python3 -m venv /opt/venv
+ source /opt/venv/bin/activate
+else
+ source /opt/venv/bin/activate
+fi
\ No newline at end of file
diff --git a/docker/base/fs/ins/install_base_packages.sh b/docker/base/fs/ins/install_base_packages.sh
new file mode 100644
index 000000000..adc7ffb2b
--- /dev/null
+++ b/docker/base/fs/ins/install_base_packages.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+set -e
+
+echo "=====BASE PACKAGES====="
+
+# Hold python3 packages to prevent overrides
+apt-mark hold python3
+
+# Install with --no-install-recommends to minimize unwanted dependencies
+apt-get install -y --no-install-recommends \
+ nodejs openssh-server sudo curl wget git ffmpeg supervisor cron
+
+
+echo "=====AFTER UPDATE====="
+
+
+echo "=====PYTHON VERSION: $(python3 --version) ====="
+echo "=====PYTHON OTHERS: $(ls /usr/bin/python*) ====="
+sleep 10
\ No newline at end of file
diff --git a/docker/base/fs/ins/install_python.sh b/docker/base/fs/ins/install_python.sh
new file mode 100644
index 000000000..11819a02c
--- /dev/null
+++ b/docker/base/fs/ins/install_python.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+set -e
+
+# echo "=====PYTHON 3.12 & SID REPO====="
+
+# apt clean
+
+# # ★ 1. Add sid repo & pin it for python 3.12
+# echo "deb http://deb.debian.org/debian sid main" > /etc/apt/sources.list.d/debian-sid.list
+# cat >/etc/apt/preferences.d/python312 <<'EOF'
+# Package: *
+# Pin: release a=sid
+# Pin-Priority: 100
+
+# Package: python3.12*
+# Pin: release a=sid
+# Pin-Priority: 990
+
+# # Prevent Python 3.13 from being installed
+# Package: python3.13*
+# Pin: release *
+# Pin-Priority: -1
+# EOF
+
+# apt-get update && apt-get -y upgrade
+
+# apt-get install -y --no-install-recommends \
+# python3.12 python3.12-venv python3.12-dev
+
+# # ★ 3. Switch the interpreter
+# # update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.13 0
+# update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1
+# update-alternatives --set python3 /usr/bin/python3.12
+
+# echo "=====PYTHON VERSION: $(python3 --version) ====="
+# echo "=====PYTHON OTHERS: $(ls /usr/bin/python*) ====="
+# sleep 10
+
+apt-get update && apt-get -y upgrade
+
+apt-get install -y --no-install-recommends \
+ python3 python3-venv python3-dev
+
+. /ins/configure_venv.sh
\ No newline at end of file
diff --git a/docker/run/Dockerfile b/docker/run/Dockerfile
index e4a7e38a4..c3f0416ba 100644
--- a/docker/run/Dockerfile
+++ b/docker/run/Dockerfile
@@ -1,24 +1,12 @@
# Use the latest slim version of Debian
-FROM debian:bookworm-slim
+FROM agent-zero-base:local
+# FROM frdel/agent-zero-base:latest
# Check if the argument is provided, else throw an error
ARG BRANCH
RUN if [ -z "$BRANCH" ]; then echo "ERROR: BRANCH is not set!" >&2; exit 1; fi
ENV BRANCH=$BRANCH
-# Set locale to en_US.UTF-8 and timezone to UTC
-RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y locales tzdata
-RUN sed -i -e 's/# \(en_US\.UTF-8 .*\)/\1/' /etc/locale.gen && \
- dpkg-reconfigure --frontend=noninteractive locales && \
- update-locale LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8
-RUN ln -sf /usr/share/zoneinfo/UTC /etc/localtime
-RUN echo "UTC" > /etc/timezone
-RUN dpkg-reconfigure -f noninteractive tzdata
-ENV LANG=en_US.UTF-8
-ENV LANGUAGE=en_US:en
-ENV LC_ALL=en_US.UTF-8
-ENV TZ=UTC
-
# Copy contents of the project to /a0
COPY ./fs/ /
@@ -39,7 +27,7 @@ RUN echo "cache buster $CACHE_DATE" && bash /ins/install_A02.sh $BRANCH
RUN bash /ins/post_install.sh $BRANCH
# Expose ports
-EXPOSE 22 80
+EXPOSE 22 80 3000-9999
RUN chmod +x /exe/initialize.sh /exe/run_A0.sh /exe/run_searxng.sh /exe/run_tunnel_api.sh
diff --git a/docker/run/DockerfileKali b/docker/run/DockerfileKali
deleted file mode 100644
index 316df9ee9..000000000
--- a/docker/run/DockerfileKali
+++ /dev/null
@@ -1,48 +0,0 @@
-# Use the latest slim version of Kali Linux
-FROM kalilinux/kali-rolling
-
-# Check if the argument is provided, else throw an error
-ARG BRANCH
-RUN if [ -z "$BRANCH" ]; then echo "ERROR: BRANCH is not set!" >&2; exit 1; fi
-ENV BRANCH=$BRANCH
-
-# Set locale to en_US.UTF-8 and timezone to UTC
-RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y locales tzdata
-RUN sed -i -e 's/# \(en_US\.UTF-8 .*\)/\1/' /etc/locale.gen && \
- dpkg-reconfigure --frontend=noninteractive locales && \
- update-locale LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8
-RUN ln -sf /usr/share/zoneinfo/UTC /etc/localtime
-RUN echo "UTC" > /etc/timezone
-RUN dpkg-reconfigure -f noninteractive tzdata
-ENV LANG=en_US.UTF-8
-ENV LANGUAGE=en_US:en
-ENV LC_ALL=en_US.UTF-8
-ENV TZ=UTC
-
-# Copy contents of the project to /a0
-COPY ./fs/ /
-
-# pre installation steps
-RUN bash /ins/pre_install.sh $BRANCH
-RUN bash /ins/pre_install_kali.sh $BRANCH
-
-# install A0
-RUN bash /ins/install_A0.sh $BRANCH
-
-# install additional software
-RUN bash /ins/install_additional.sh $BRANCH
-
-# cleanup repo and install A0 without caching, this speeds up builds
-ARG CACHE_DATE=none
-RUN echo "cache buster $CACHE_DATE" && bash /ins/install_A02.sh $BRANCH
-
-# post installation steps
-RUN bash /ins/post_install.sh $BRANCH
-
-# Expose ports
-EXPOSE 22 80
-
-RUN chmod +x /exe/initialize.sh /exe/run_A0.sh /exe/run_searxng.sh
-
-# initialize runtime and switch to supervisord
-CMD ["/exe/initialize.sh", "$BRANCH"]
diff --git a/docker/run/fs/etc/searxng/settings.yml b/docker/run/fs/etc/searxng/settings.yml
index bafdc17cf..61ddae77f 100644
--- a/docker/run/fs/etc/searxng/settings.yml
+++ b/docker/run/fs/etc/searxng/settings.yml
@@ -16,6 +16,7 @@ search:
server:
# Is overwritten by ${SEARXNG_SECRET}
secret_key: "dummy"
+ port: 55510
limiter: false
image_proxy: false
# public URL of the instance, to ensure correct inbound links. Is overwritten
diff --git a/docker/run/fs/exe/run_tunnel_api.sh b/docker/run/fs/exe/run_tunnel_api.sh
index 6be00ba2c..321697ea8 100644
--- a/docker/run/fs/exe/run_tunnel_api.sh
+++ b/docker/run/fs/exe/run_tunnel_api.sh
@@ -14,7 +14,7 @@ done
exec python /a0/run_tunnel.py \
--dockerized=true \
--port=80 \
- --tunnel_api_port=5070 \
+ --tunnel_api_port=55520 \
--host="0.0.0.0" \
--code_exec_docker_enabled=false \
--code_exec_ssh_enabled=true \
diff --git a/docker/run/fs/ins/install_playwright.sh b/docker/run/fs/ins/install_playwright.sh
index eca6ab98a..c823a6019 100644
--- a/docker/run/fs/ins/install_playwright.sh
+++ b/docker/run/fs/ins/install_playwright.sh
@@ -8,11 +8,11 @@ pip install playwright
# install chromium with dependencies
# for kali-based
-if [ "$@" = "hacking" ]; then
+# if [ "$@" = "hacking" ]; then
apt-get install -y fonts-unifont libnss3 libnspr4
playwright install chromium-headless-shell
-else
- # for debian based
- playwright install --with-deps chromium-headless-shell
-fi
+# else
+# # for debian based
+# playwright install --with-deps chromium-headless-shell
+# fi
diff --git a/docker/run/fs/ins/pre_install.sh b/docker/run/fs/ins/pre_install.sh
index a073183cb..3ba865e55 100644
--- a/docker/run/fs/ins/pre_install.sh
+++ b/docker/run/fs/ins/pre_install.sh
@@ -3,45 +3,5 @@
# fix permissions for cron files
chmod 0644 /etc/cron.d/*
-echo "=====BEFORE UPDATE====="
-
-# Update and install necessary packages
-apt clean
-apt-get update && apt-get upgrade -y && apt-get install -y \
- python3 \
- python3-venv \
- python3-pip \
- nodejs \
- openssh-server \
- sudo \
- curl \
- wget \
- git \
- ffmpeg \
- supervisor \
- cron
-
-echo "=====MID UPDATE====="
-
-# for some reason npm crashes builds on amd64 in this version and has to be installed separately
-# A0 can install it when needed
-# apt-get install -y \
-# npm
-
-echo "=====AFTER UPDATE====="
-
-# # Configure system alternatives so that /usr/bin/python3 points to Python 3.12
-# sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1
-# sudo update-alternatives --set python3 /usr/bin/python3.12
-
-# Update pip3 symlink: if pip3.12 exists, point pip3 to it;
-# otherwise, install pip using Python 3.12's ensurepip.
-# if [ -f /usr/bin/pip3.12 ]; then
-# sudo ln -sf /usr/bin/pip3.12 /usr/bin/pip3
-# else
-# python3 -m ensurepip --upgrade
-# python3 -m pip install --upgrade pip
-# fi
-
# Prepare SSH daemon
bash /ins/setup_ssh.sh "$@"
diff --git a/docker/run/fs/ins/pre_install_kali.sh b/docker/run/fs/ins/pre_install_kali.sh
deleted file mode 100644
index dffcbdff3..000000000
--- a/docker/run/fs/ins/pre_install_kali.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/bash
-
-# ubuntu based dependencies for playwright
-# moved to install_playwright.sh
-# apt-get update && apt-get install -y fonts-unifont fonts-ubuntu
-
diff --git a/python/api/tunnel_proxy.py b/python/api/tunnel_proxy.py
index 16372a42f..efcd39a77 100644
--- a/python/api/tunnel_proxy.py
+++ b/python/api/tunnel_proxy.py
@@ -11,7 +11,7 @@ class TunnelProxy(ApiHandler):
tunnel_api_port = (
runtime.get_arg("tunnel_api_port")
or int(dotenv.get_dotenv_value("TUNNEL_API_PORT", 0))
- or 5070
+ or 55520
)
# first verify the service is running:
diff --git a/python/helpers/runtime.py b/python/helpers/runtime.py
index 6fa9cc7b0..ec774af5c 100644
--- a/python/helpers/runtime.py
+++ b/python/helpers/runtime.py
@@ -138,6 +138,6 @@ def get_tunnel_api_port():
tunnel_api_port = (
get_arg("tunnel_api_port")
or int(dotenv.get_dotenv_value("TUNNEL_API_PORT", 0))
- or 5070
+ or 55520
)
return tunnel_api_port
\ No newline at end of file
diff --git a/python/helpers/searxng.py b/python/helpers/searxng.py
index 2ba19f6dc..e51d98950 100644
--- a/python/helpers/searxng.py
+++ b/python/helpers/searxng.py
@@ -1,7 +1,7 @@
import aiohttp
from python.helpers import runtime
-URL = "http://localhost:8888/search"
+URL = "http://localhost:55510/search"
async def search(query:str):
return await runtime.call_development_function(_search, query=query)
diff --git a/requirements.txt b/requirements.txt
index a2cb4d1f1..293811596 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -24,7 +24,7 @@ newspaper3k==0.2.8
paramiko==3.5.0
playwright==1.52.0
pypdf==4.3.1
-python-dotenv==1.0.1
+python-dotenv==1.1.0
pytz==2024.2
sentence-transformers==3.0.1
tiktoken==0.8.0