-
Notifications
You must be signed in to change notification settings - Fork 0
Build proactive custom AI bot with VM testing and vision capabilities #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,150 @@ | ||
| # OmniBlocks Proactive AI Bot | ||
|
|
||
| A groundbreaking proactive AI bot with VM testing and vision capabilities for the OmniBlocks organization. | ||
|
|
||
| ## Overview | ||
|
|
||
| This bot represents a new paradigm in AI development tools - instead of being reactive (waiting for mentions/triggers), it operates proactively by: | ||
|
|
||
| - **Always monitoring** repository activity autonomously | ||
| - **Testing code** in real, isolated VM environments | ||
| - **Providing visual feedback** with screenshots and UI interaction | ||
| - **Managing resources** intelligently with smart wake/sleep cycles | ||
|
|
||
| ## Key Features | ||
|
|
||
| ### 🤖 Proactive Operation | ||
| - Continuous repository monitoring and engagement | ||
| - Intelligent sleep/wake scheduling to optimize token usage | ||
| - Smart pattern recognition for proactive intervention | ||
| - Event-driven architecture with real-time processing | ||
|
|
||
| ### 🔬 VM Testing Environment | ||
| - Isolated Docker containers for safe code execution | ||
| - Automated testing workflows with comprehensive reporting | ||
| - Security sandboxing to prevent malicious code execution | ||
| - Resource cleanup and management | ||
|
|
||
| ### 👁️ Vision & Multimodal Capabilities | ||
| - Screenshot capture and visual analysis | ||
| - UI element detection and interaction | ||
| - Visual debugging and change detection | ||
| - Integration with vision-enabled LLM models | ||
|
|
||
| ### 🔧 Advanced Integration | ||
| - GitHub Actions and Octokit API integration | ||
| - Multi-provider LLM support (OpenAI, Anthropic, etc.) | ||
| - Webhook processing for real-time events | ||
| - Comprehensive logging and monitoring | ||
|
|
||
| ## Architecture | ||
|
|
||
| ``` | ||
| omniblocks-ai-bot/ | ||
| ├── src/ | ||
| │ ├── core/ # Core bot engine and orchestration | ||
| │ ├── monitoring/ # Repository monitoring and event processing | ||
| │ ├── testing/ # VM testing environment and execution | ||
| │ ├── vision/ # Computer vision and UI interaction | ||
| │ ├── github/ # GitHub API integration and webhooks | ||
| │ ├── llm/ # LLM integration and intelligence | ||
| │ └── utils/ # Shared utilities and helpers | ||
| ├── config/ # Configuration files and templates | ||
| ├── docker/ # Docker configurations for VM testing | ||
| ├── workflows/ # GitHub Actions workflows | ||
| ├── tests/ # Comprehensive test suite | ||
| └── docs/ # Documentation and guides | ||
| ``` | ||
|
|
||
| ## Quick Start | ||
|
|
||
| 1. **Clone and Setup** | ||
| ```bash | ||
| git clone <repository-url> | ||
| cd omniblocks-ai-bot | ||
| pip install -r requirements.txt | ||
| ``` | ||
|
|
||
| 2. **Configure Environment** | ||
| ```bash | ||
| cp config/env.example .env | ||
| # Edit .env with your API keys and settings | ||
| ``` | ||
|
|
||
| 3. **Run the Bot** | ||
| ```bash | ||
| python -m src.main | ||
| ``` | ||
|
|
||
| ## Configuration | ||
|
|
||
| The bot uses environment variables for configuration: | ||
|
|
||
| - `GITHUB_TOKEN` - GitHub API token with appropriate permissions | ||
| - `OPENAI_API_KEY` - OpenAI API key for LLM integration | ||
| - `ANTHROPIC_API_KEY` - Anthropic API key (optional) | ||
| - `BOT_MODE` - Operation mode: `proactive`, `reactive`, or `hybrid` | ||
| - `SLEEP_SCHEDULE` - Sleep/wake schedule configuration | ||
| - `VM_RESOURCE_LIMITS` - Resource limits for VM testing | ||
|
|
||
| ## Development | ||
|
|
||
| ### Prerequisites | ||
| - Python 3.9+ | ||
| - Docker and Docker Compose | ||
| - Git | ||
|
|
||
| ### Setup Development Environment | ||
| ```bash | ||
| python -m venv venv | ||
| source venv/bin/activate # On Windows: venv\Scripts\activate | ||
| pip install -r requirements-dev.txt | ||
| pre-commit install | ||
| ``` | ||
|
|
||
| ### Running Tests | ||
| ```bash | ||
| pytest tests/ | ||
| ``` | ||
|
|
||
| ### Code Quality | ||
| ```bash | ||
| black src/ tests/ | ||
| flake8 src/ tests/ | ||
| mypy src/ | ||
| ``` | ||
|
|
||
| ## Security | ||
|
|
||
| This bot handles sensitive operations including: | ||
| - Code execution in isolated environments | ||
| - API key management | ||
| - Repository access and modifications | ||
|
|
||
| Security measures include: | ||
| - Sandboxed VM execution with resource limits | ||
| - Encrypted API key storage | ||
| - Audit logging of all operations | ||
| - Rate limiting and abuse prevention | ||
|
|
||
| ## Contributing | ||
|
|
||
| 1. Fork the repository | ||
| 2. Create a feature branch | ||
| 3. Make your changes with tests | ||
| 4. Submit a pull request | ||
|
|
||
| ## License | ||
|
|
||
| This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details. | ||
|
|
||
| ## Support | ||
|
|
||
| For questions, issues, or contributions: | ||
| - Open an issue on GitHub | ||
| - Contact @supervoidcoder | ||
| - Reference: OmniBlocks/scratch-gui#249 | ||
|
|
||
| --- | ||
|
|
||
| **Note**: This is a groundbreaking implementation of proactive AI bot technology. Most existing bots are reactive, but this system actively monitors and engages with repositories autonomously while maintaining intelligent resource management. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| # OmniBlocks Proactive AI Bot Configuration | ||
| # Copy this file to .env and fill in your values | ||
|
|
||
| # GitHub Configuration | ||
| GITHUB_TOKEN=your_github_token_here | ||
| GITHUB_WEBHOOK_SECRET=your_webhook_secret_here | ||
| GITHUB_REPOSITORY=owner/repo-name | ||
| GITHUB_ORGANIZATION=your-org-name | ||
| GITHUB_API_BASE_URL=https://api.github.com | ||
|
|
||
| # LLM Configuration | ||
| OPENAI_API_KEY=your_openai_api_key_here | ||
| ANTHROPIC_API_KEY=your_anthropic_api_key_here | ||
| LLM_DEFAULT_PROVIDER=openai | ||
| LLM_MAX_TOKENS=4000 | ||
| LLM_TEMPERATURE=0.7 | ||
| LLM_VISION_MODEL=gpt-4-vision-preview | ||
|
|
||
| # VM Testing Configuration | ||
| VM_DOCKER_IMAGE=python:3.9-slim | ||
| VM_MEMORY_LIMIT=512m | ||
| VM_CPU_LIMIT=0.5 | ||
| VM_TIMEOUT_SECONDS=300 | ||
| VM_NETWORK_MODE=none | ||
| VM_ENABLE_GPU=false | ||
|
|
||
| # Monitoring Configuration | ||
| MONITORING_POLL_INTERVAL=60 | ||
| MONITORING_MAX_EVENTS=10 | ||
| MONITORING_EVENT_TYPES=push,pull_request,issues,issue_comment,pull_request_review | ||
| MONITORING_IGNORE_BOTS=true | ||
|
|
||
| # Scheduling Configuration | ||
| SCHEDULING_ENABLE_SLEEP=true | ||
| SCHEDULING_SLEEP_DURATION=30 | ||
| SCHEDULING_WAKE_TRIGGERS=high_priority_event,mention,scheduled_time | ||
| SCHEDULING_QUIET_START=22:00 | ||
| SCHEDULING_QUIET_END=06:00 | ||
| SCHEDULING_TIMEZONE=UTC | ||
|
|
||
| # Vision Configuration | ||
| VISION_SCREENSHOT_QUALITY=85 | ||
| VISION_MAX_SCREENSHOT_SIZE=1920,1080 | ||
| VISION_UI_TIMEOUT=30 | ||
| VISION_DIFF_THRESHOLD=0.1 | ||
| VISION_ENABLE_OCR=true | ||
|
|
||
| # Security Configuration | ||
| SECURITY_ENABLE_SCANNING=true | ||
| SECURITY_ALLOWED_EXTENSIONS=.py,.js,.ts,.json,.yaml,.yml,.md,.txt | ||
| SECURITY_BLOCKED_COMMANDS=rm -rf,sudo,curl,wget,nc,netcat | ||
| SECURITY_MAX_FILE_SIZE_MB=10 | ||
|
|
||
| # Logging Configuration | ||
| LOG_LEVEL=INFO | ||
| LOG_DIR=logs | ||
| LOG_JSON=false | ||
|
|
||
| # State Management | ||
| STATE_DIR=state | ||
|
|
||
| # Bot Mode | ||
| BOT_MODE=proactive |
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,30 @@ | ||||||||||||
| # Dockerfile for secure testing environment | ||||||||||||
| FROM python:3.9-slim | ||||||||||||
|
|
||||||||||||
| # Install system dependencies | ||||||||||||
| RUN apt-get update && apt-get install -y \ | ||||||||||||
| git \ | ||||||||||||
| curl \ | ||||||||||||
| wget \ | ||||||||||||
| build-essential \ | ||||||||||||
| && rm -rf /var/lib/apt/lists/* | ||||||||||||
|
|
||||||||||||
| # Create non-root user for security | ||||||||||||
| RUN useradd -m -u 1000 testuser | ||||||||||||
|
|
||||||||||||
| # Set up working directory | ||||||||||||
| WORKDIR /workspace | ||||||||||||
|
|
||||||||||||
| # Copy requirements and install Python dependencies | ||||||||||||
| COPY requirements-testing.txt . | ||||||||||||
| RUN pip install --no-cache-dir -r requirements-testing.txt | ||||||||||||
|
|
||||||||||||
|
Comment on lines
+19
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainCOPY source path is wrong for typical build context (breaks build). When building with Apply this diff: -# Copy requirements and install Python dependencies
-COPY requirements-testing.txt .
-RUN pip install --no-cache-dir -r requirements-testing.txt
+# Copy requirements and install Python dependencies
+COPY docker/requirements-testing.txt /tmp/requirements-testing.txt
+RUN python -m pip install --no-cache-dir -r /tmp/requirements-testing.txt🏁 Script executed: #!/bin/bash
# Verify file location and absence at repo root
set -euo pipefail
echo "Listing matches for requirements-testing.txt:"
fd -a --hidden --no-ignore -g "*requirements-testing.txt"
echo
if [ -f "requirements-testing.txt" ]; then
echo "Found requirements-testing.txt at repo root (unexpected)."
else
echo "No requirements-testing.txt at repo root (expected)."
fiLength of output: 150 COPY path is incorrect and breaks the build—apply the fix. The file is located at -COPY requirements-testing.txt .
-RUN pip install --no-cache-dir -r requirements-testing.txt
+COPY docker/requirements-testing.txt /tmp/requirements-testing.txt
+RUN python -m pip install --no-cache-dir -r /tmp/requirements-testing.txt📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||
| # Switch to non-root user | ||||||||||||
| USER testuser | ||||||||||||
|
|
||||||||||||
| # Set environment variables | ||||||||||||
| ENV PYTHONPATH=/workspace | ||||||||||||
| ENV PYTHONUNBUFFERED=1 | ||||||||||||
|
|
||||||||||||
| # Default command | ||||||||||||
| CMD ["python", "-c", "print('Testing environment ready')"] | ||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Testing environment requirements | ||
| pytest>=7.4.0 | ||
| pytest-asyncio>=0.21.0 | ||
| pytest-cov>=4.1.0 | ||
| pytest-mock>=3.11.0 | ||
|
|
||
| # Common testing libraries | ||
| requests>=2.31.0 | ||
| numpy>=1.24.0 | ||
| pandas>=2.0.0 | ||
|
|
||
| # Code analysis | ||
| flake8>=6.0.0 | ||
| black>=23.7.0 | ||
| mypy>=1.5.0 | ||
|
|
||
| # Security scanning | ||
| bandit>=1.7.5 | ||
| safety>=2.3.0 |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,45 @@ | ||||||||
| # Core dependencies | ||||||||
| asyncio | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove asyncio from dependencies.
Apply this diff: # Core dependencies
-asyncio
aiohttp>=3.8.0📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||
| aiohttp>=3.8.0 | ||||||||
| aiofiles>=0.8.0 | ||||||||
|
|
||||||||
| # GitHub integration | ||||||||
| PyGithub>=1.58.0 | ||||||||
|
|
||||||||
| # LLM integrations | ||||||||
| openai>=1.0.0 | ||||||||
| anthropic>=0.7.0 | ||||||||
|
|
||||||||
| # Computer vision and image processing | ||||||||
| opencv-python>=4.8.0 | ||||||||
| Pillow>=10.0.0 | ||||||||
| pytesseract>=0.3.10 | ||||||||
|
|
||||||||
| # Docker integration | ||||||||
| docker>=6.0.0 | ||||||||
|
|
||||||||
| # Data processing | ||||||||
| pandas>=2.0.0 | ||||||||
| numpy>=1.24.0 | ||||||||
|
|
||||||||
| # Configuration and utilities | ||||||||
| python-dotenv>=1.0.0 | ||||||||
| pydantic>=2.0.0 | ||||||||
| pytz>=2023.3 | ||||||||
|
|
||||||||
| # Logging and monitoring | ||||||||
| structlog>=23.1.0 | ||||||||
|
|
||||||||
| # Testing | ||||||||
| pytest>=7.4.0 | ||||||||
| pytest-asyncio>=0.21.0 | ||||||||
| pytest-mock>=3.11.0 | ||||||||
|
|
||||||||
| # Code quality | ||||||||
| black>=23.7.0 | ||||||||
| flake8>=6.0.0 | ||||||||
| mypy>=1.5.0 | ||||||||
| pre-commit>=3.3.0 | ||||||||
|
|
||||||||
| # Security | ||||||||
| cryptography>=41.0.0 | ||||||||
|
Comment on lines
+1
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify dependency versions for security vulnerabilities. Several dependencies are specified with minimum versions from 2023-2024. Ensure these versions are free from known security vulnerabilities and consider updating to the latest stable versions. 🏁 Script executed: #!/bin/bash
# Check for security vulnerabilities in specified dependencies
echo "Checking for security advisories..."
# Key dependencies to check
packages=("Pillow" "cryptography" "opencv-python" "PyGithub" "openai" "anthropic" "aiohttp")
for package in "${packages[@]}"; do
echo "=== Checking $package ==="
gh api graphql -f query="
{
securityVulnerabilities(first: 5, ecosystem: PIP, package: \"$package\") {
nodes {
advisory {
summary
severity
publishedAt
}
vulnerableVersionRange
firstPatchedVersion {
identifier
}
}
}
}"
echo ""
doneLength of output: 5202 Update minimum versions to patch known security vulnerabilities. Security advisory checks reveal active vulnerabilities in four dependencies:
🤖 Prompt for AI Agents |
||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| """ | ||
| OmniBlocks Proactive AI Bot | ||
|
|
||
| A groundbreaking proactive AI bot with VM testing and vision capabilities. | ||
| """ | ||
|
|
||
| __version__ = "1.0.0" | ||
| __author__ = "OmniBlocks Organization" | ||
| __description__ = "Proactive AI Bot with VM Testing and Vision Capabilities" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| """ | ||
| Core module for the OmniBlocks Proactive AI Bot. | ||
|
|
||
| This module contains the core bot engine, configuration management, | ||
| and orchestration components. | ||
| """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Ensure workspace permissions for non-root and align PYTHONPATH with src layout.
Without chown,
testusermay lack write access to/workspace. Also, imports come fromsrc/, so expose that path.Python 3.9 reaches/has reached EOL around October 2025. Consider
python:3.11-slimto stay in support windows.Also applies to: 23-27
🤖 Prompt for AI Agents