nimesh24/computer-use-agent
0
Computer Use Agent ๐ค
An AI autonomous agent powered by Google Gemini 2.5 and Playwright. It browses the web, extracts information, and saves summaries to local files, all while operating within a secure, sandboxed environment.
Now features a Streamlit Web Interface for easy interaction and Docker support for cloud deployment.
๐ Features
- ๐ง AI-Powered Browsing: Uses Gemini 2.5's computer use capabilities to navigate websites and interact with elements.
- ๐ก๏ธ Secure by Design: Custom "Security Kernel" (
security.py) prevents prompt injection, restricts browsing to allowed domains (Wikipedia), and sandboxes file access. - ๐ป Dual Interface:
- Web UI: User-friendly dashboard built with Streamlit.
- CLI: Direct terminal access for power users.
- ๐ณ Docker Ready: Containerized environment for safe and easy deployment to Hugging Face Spaces or any cloud provider.
- ๐ Automatic Summarization: Reads articles and creates structured text summaries in a designated output folder.
๐ Project Structure
computer-use-agent/
โโโ app.py # ๐ฅ๏ธ Streamlit Web Interface (Entry Point)
โโโ agent.py # ๐ง Main Agent Logic (Gemini + Playwright)
โโโ security.py # ๐ Security Guardrails (Policy Enforcement)
โโโ Dockerfile # ๐ณ Container configuration
โโโ requirements.txt # ๐ฆ Python dependencies
โโโ .env # ๐ API Keys (Optional)
โโโ runs/ # ๐ Output folder for generated files
๐ Quick Start
Prerequisites
- Google GenAI API Key: Get one from Google AI Studio.
Option 1: Run with Docker (Recommended)
This method guarantees the browser installs correctly without messing up your local machine.
- Build the Container:
docker build -t browser-agent .
- Run the App:
docker run -p 8501:8501 browser-agent
- Open Browser: Go to
http://localhost:8501
Option 2: Run Locally
- Clone & Install:
git clone https://github.com/yourusername/computer-use-agent.git
cd computer-use-agent
pip install -r requirements.txt
playwright install chromium
- Start the Web UI:
streamlit run app.py
- Start via CLI (Alternative):
# Set key first: export GOOGLE_API_KEY=AIzaSy...
python agent.py "Find information about Apollo 11"
๐ Security Architecture
This project implements a Policy Enforcement Point (PEP) pattern in security.py to ensure the AI behaves safely.
๐ ๏ธ Configuration
You can configure the agent via the Web UI sidebar or by setting environment variables in a .env file.
โ๏ธ Deployment
Deploy to Hugging Face Spaces
- Create a new Space on Hugging Face.
- Select Docker as the SDK.
- Upload all project files (
Dockerfile,app.py, etc.). - Hugging Face will automatically build and launch your agent!
๐ License
This project is open-source.
Author: Sachintha Dissanayaka
