Skip to content

aaravshah1311/Agent-2-Beta

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

⚑ Agent-2-Beta

A self-hosted autonomous AI development agent powered by Google Gemini β€”
coding assistant, terminal agent, security tester, and persistent memory in one interface.

Overview β€’ Install β€’ Run β€’ Keys β€’ CLI β€’ Troubleshoot β€’ Pro Version β€’ Contribute


πŸš€ Overview

Agent-2-Beta is a self-hosted autonomous AI agent powered by Google Gemini. It ships in two modes:

Mode Entry point Description
🌐 Web UI agent2web.py Browser interface β€” workspaces, multi-tab terminals, Three.js 3D welcome, real-time streaming
⚑ CLI agent2cli.py Terminal-native agent β€” same brain, tools, and memory as the web UI

Both modes share the same 8 agentic tools, persistent memory engine, and .env-based API key rotation.


✨ Core Features

Feature Description
πŸ—‚οΈ Workspaces Claude Projects-style context β€” path browser, per-workspace memory, framework detection
πŸ€– 8 Agent Tools Shell, file R/W, directory tree, project analyzer, web search, memory, planner
🧠 Persistent Memory Global, workspace-scoped, and auto-extracted memories across sessions
πŸ’» Multi-tab Terminals Live streaming, stdin injection, ↑↓ command history, 2-stage kill
πŸ”‘ API Key Rotation Multiple keys, auto-rotate on quota, pin a key, per-key usage stats
πŸ”’ Security Testing nmap, nikto, gobuster, sqlmap, hydra, metasploit β€” built-in workflows
🌐 Web Search DuckDuckGo instant answers β€” no extra API key required
✏️ Message Editing Edit any past message and re-run the agent from that point
⏹️ Stop Generation Cancel agent mid-flight at any time
πŸ“Ž File Attachments Attach code, images, PDFs as context
▢️ One-click Run Click β–Ά on any tool block to instantly run that command in the active terminal
🎨 3D Welcome Screen Three.js β€” neural particles, torus knot, rotating wireframes, octahedron
πŸ“¦ Project Auto-Setup Detect framework β†’ install deps β†’ run project automatically

πŸ–ΌοΈ Screenshots

Agent2 Web Interface Agent2 Installation

Left: Web Interface Β β€’Β  Right: Installation & Setup


Agent2 CLI

Agent2 CLI β€” Rich UI, key rotation, ↑↓ history, and all 8 tools in the terminal


🧱 Project Structure

agent2/
β”œβ”€β”€ run.py                  ← Universal launcher β€” setup, run, manage keys
β”œβ”€β”€ agent2web.py            ← Web UI entry point
β”œβ”€β”€ agent2cli.py            ← CLI agent entry point
β”œβ”€β”€ .env                    ← API keys  (auto-created on first run)
β”œβ”€β”€ agent2.db               ← SQLite database  (auto-created)
└── agent2/
    β”œβ”€β”€ __init__.py
    β”œβ”€β”€ config.py           ← Platform detection, models, modes, constants
    β”œβ”€β”€ database.py         ← SQLite helpers + schema + migrations
    β”œβ”€β”€ memory.py           ← Memory engine (auto-extract, workspace-scoped)
    β”œβ”€β”€ tools.py            ← 8 tool implementations
    β”œβ”€β”€ keys.py             ← KeyRotator: rotation, pinning, usage tracking
    β”œβ”€β”€ terminal.py         ← stream_command, stdin, kill, stop events
    β”œβ”€β”€ agent.py            ← system_prompt, context builder, run_agent loop
    β”œβ”€β”€ routes.py           ← All /api/* REST endpoints
    β”œβ”€β”€ sockets.py          ← All Socket.IO event handlers
    └── ui.py               ← HTML/CSS/JS single-page frontend  (89 KB)

βš™οΈ Installation

1 β€” Clone

git https://github.com/aaravshah1311/Agent-2-Beta.git
cd Agent-2-Beta

2 β€” Run the launcher

python run.py

run.py will automatically:

  • βœ… Create a virtual environment
  • βœ… Install all dependencies (flask, flask-socketio, google-genai, rich, …)
  • βœ… Prompt for your Gemini API key and save it to .env
  • βœ… Start the web server

πŸ”‘ Free Gemini API key β†’ https://aistudio.google.com/app/apikey


▢️ Run Modes

run.py β€” all flags at a glance

python run.py                 setup + start Web UI  (default)
python run.py --web           setup + start Web UI
python run.py --cli           setup + start CLI agent
python run.py --addapi        add / manage API keys
python run.py --reset         wipe venv and reinstall everything
python run.py --uninstall     completely remove Agent2 and its venv
python run.py -h              show this help menu

🌐 Web UI

python run.py
# or explicitly
python run.py --web

Opens at β†’ http://localhost:1311


⚑ CLI Agent

python run.py --cli

Or call directly after first setup:

# macOS / Linux
venv/bin/python agent2cli.py

# Windows
venv\Scripts\python agent2cli.py

One-shot mode (pipe-friendly, just like gemini -m flash "..."):

venv/bin/python agent2cli.py "portscan 10.10.1.1"
venv/bin/python agent2cli.py --model 2.5-flash "explain this error"
venv/bin/python agent2cli.py --mode thinking "design this architecture"
venv/bin/python agent2cli.py --clear "start a fresh session"

πŸ”‘ Managing API Keys

Via run.py β€” recommended

python run.py --addapi

Walks you through adding keys interactively and saves them to .env.
Keys are stored as GEMINI_API_KEY, GEMINI_API_KEY_2, GEMINI_API_KEY_3 … and auto-rotated when one exhausts its quota. No downtime β€” the next key is picked up on the very next request.

Inside a CLI session

/addapi

Paste a new key without leaving the session β€” saved to .env immediately and active on the next call.

Reset everything

python run.py --reset

Wipes venv/ and reinstalls all dependencies. Use when packages break or Python is upgraded.

Full uninstall

python run.py --uninstall

Removes the virtual environment and generated files, leaving source code intact.


πŸ—‚οΈ First Run β€” Workspace Setup (Web UI)

  1. Open http://localhost:1311
  2. Click + Create Workspace in the sidebar
  3. Enter a name and optionally a project path β€” leave blank to auto-create a folder
  4. Click the workspace β†’ New Chat β†’ start working

Every chat belongs to a workspace. The agent always knows your project path, detected framework, and accumulated workspace memories.


⌨️ CLI Commands Reference

Command Description
/help Show all commands
/addapi Add a Gemini API key to .env
/keys Show current API key status and usage
/model [name] Switch model (2.5-flash-lite Β· 2.5-flash Β· 2.5-pro Β· 3.1-*)
/mode [name] Switch mode (fast ⚑ Β· pro β˜… Β· thinking 🧠)
/clear Clear current conversation and start fresh
/history Show last 10 messages
/memory List all saved memories with importance scores
/addmem <text> Save a memory manually
/workspace [path] Show or set working directory for commands
/run <cmd> Run a shell command directly in the current workspace
/read <file> Read and display a file's contents
/write <file> Write text to a file (prompts for content)
/ls [path] Display a recursive directory tree
/analyze <path> Detect framework / language / dependencies / run command
/search <query> Web search via DuckDuckGo (no key required)
/exit Β· Ctrl+C Quit

πŸ§ͺ Setup Checklist

  • Python 3.10+ installed
  • python run.py completed without errors
  • Gemini API key saved to .env
  • Web UI β†’ server starts at http://localhost:1311, first workspace created
  • CLI β†’ prompt you [no-ws|2.5-flash-lite|β˜…]> appears

πŸ€– Models Available

Key Model Group
2.5-flash-lite Gemini 2.5 Flash Lite 2.5
2.5-flash Gemini 2.5 Flash 2.5
2.5-pro Gemini 2.5 Pro 2.5
3.1-flash-lite Gemini 3.1 Flash Lite 3.1
3.1-flash Gemini 3.1 Flash 3.1
3.1-pro Gemini 3.1 Pro 3.1

⚑ Reasoning Modes

Mode Max Tokens Best for
⚑ Fast 2 048 Quick answers, simple commands β€” lowest cost
β˜… Pro 8 192 Most tasks β€” balanced speed and quality
🧠 Thinking 16 384 Complex reasoning, architecture, hard bugs (2.5 / 3.1 only)

πŸ› οΈ Tech Stack

Layer Technology
Backend Python 3.10+, Flask, Flask-SocketIO
AI Engine Google Gemini (google-genai)
Database SQLite (stdlib sqlite3)
Terminal subprocess.Popen β€” live stdout streaming
Web frontend Vanilla JS, xterm.js, marked.js, highlight.js, Three.js
3D scene Three.js r128 β€” particles, torus knot, icosahedra, octahedron
CLI UI Rich β€” panels, markdown, syntax highlight, spinner
Memory Auto-extraction via background Gemini call after each reply
Web search DuckDuckGo Instant Answer API β€” no key required

πŸ”’ Security Testing Workflows

Agent-2-Beta is purpose-built for security research and CTF work:

portscan 10.10.1.1
enumerate http://target:8080 with gobuster
run sqlmap on http://target/login?id=1
check for open ports on localhost
scan for vulnerabilities on 192.168.1.0/24
brute force SSH on 10.10.1.5 with hydra

Supports: nmap, nikto, gobuster, ffuf, sqlmap, hydra, metasploit, searchsploit, theharvester, binwalk, strings, volatility, and more.


πŸ“Œ Troubleshooting

Problem Solution
No API keys configured python run.py --addapi or type /addapi in the CLI
Key quota exhausted Keys rotate automatically. Add more: python run.py --addapi
Model returns empty response Switch to 2.5 Flash Lite: /model 2.5-flash-lite
Terminal not showing output Refresh the browser tab and reconnect
python not found on Windows Use py run.py or install from the Microsoft Store
Port 1311 already in use Change port=1311 in agent2web.py to another port
Broken venv / import errors python run.py --reset β€” wipes and reinstalls cleanly
CLI spinner frozen Ctrl+C β€” cancels the request and returns to prompt
rich not installed python run.py --reset β€” rich is included in the install list
Want to start completely fresh python run.py --uninstall then python run.py

πŸš€ Agent-2-Pro

Unlock the full power of autonomous AI engineering.

Agent-2-Pro is the professional-grade evolution of Agent-2-Beta β€” a proper Software Engineer and Brutal Pentester in one agent.

Agent-2-Beta Agent-2-Pro
Workspaces βœ… βœ…
8 Agent Tools βœ… βœ… Extended
Memory Engine βœ… βœ… Advanced
Multi-tab Terminals βœ… βœ…
Full-project generation from one prompt ❌ βœ…
Software Engineering mode ❌ βœ…
DeepDive β€” task decomposition ❌ βœ…
Brutal Penetration Testing ❌ βœ…
QA & automated test generation ❌ βœ…
Project Space ❌ βœ…

Pro Feature Highlights

πŸ—οΈ Software Engineering Mode Analyzes your prompt, architects the full solution, and engineers a complete multi-file project in a series of precise, self-correcting steps. One prompt β†’ production-ready codebase.

🎯 DeepDive Breaks a single complex task into multiple focused sub-tasks, solves each with precision, then assembles the final result. Dramatically higher accuracy on hard problems.

πŸ”΄ Brutal Pentester Goes far beyond basic scanning β€” full kill-chain automation: recon β†’ enumeration β†’ exploitation β†’ post-exploitation β†’ report generation, all in one session.

πŸ§ͺ QA Mode Automatically generates unit tests, integration tests, and edge-case coverage for any codebase it builds or is given.

Get Agent-2-Pro

πŸ“§ Contact: aaravprogrammers@gmail.com πŸ™ GitHub: github.com/aaravshah1311


🀝 Contributing

Contributions are welcome and appreciated! Agent-2-Beta is open to improvements in any area.

How to contribute

  1. Fork the repository
  2. Create a feature branch
    git checkout -b feature/your-feature-name
  3. Make your changes and commit with a clear message
    git commit -m "feat: add your feature description"
  4. Push to your fork
    git push origin feature/your-feature-name
  5. Open a Pull Request against main

What we're looking for

  • πŸ› Bug fixes β€” especially edge cases on Windows/Mac/Linux
  • 🌐 New tools β€” additional agent capabilities
  • 🎨 UI improvements β€” frontend polish, accessibility
  • πŸ“š Documentation β€” clearer explanations, more examples
  • πŸ”’ Security workflows β€” new pentest automation patterns
  • ⚑ Performance β€” faster startup, lower memory, better streaming
  • 🌍 Portability β€” improvements for different platforms or Python versions

Guidelines

  • Keep changes focused β€” one PR per feature/fix
  • Follow the existing code style in each file
  • Test on at least one platform before submitting
  • Add a brief description in the PR explaining what and why

Report issues

Found a bug or have a feature request? Open an issue β€” please include your OS, Python version, and the exact error message.


πŸ‘€ Authors

Aarav Shah GitHub Portfolio Email

Rudra Marathe GitHub Portfolio Email

Naitik Soni GitHub Email


⭐ Star this repo if Agent-2-Beta helps you build or break things.


Built for developers, security researchers, and anyone who wants an AI that actually does things.

About

Agent2 is a self-hosted, browser-based autonomous AI agent powered by aaravprogrammers that combines a coding assistant, real terminal access, security testing tools, persistent memory, and a workspace system into a single unified interface.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors