A local-first agentic browser + security firewall stack:
- A FastAPI backend that runs an autonomous web agent on your current Chrome tab (CDP attach).
- A Chrome extension that injects a persistent in-page overlay panel (modern “AI browser” UX).
- A multi-layer page threat analyzer (DOM + NLP + optional LLM) with “block/confirm/allow” recommendations.
- Persistent agent memory (SQLite + FTS5) for RAG-style recall across runs.
Everything runs locally: the extension talks to
http://127.0.0.1:8001.
- Open any normal webpage.
- Use the in-page overlay (top-right): Run.
- The backend attaches to the active Chrome tab and executes steps safely.
- Use Analyze in the overlay.
- Sends page HTML to the local firewall and returns a human-readable security report.
The extension injects a floating panel on normal http(s) pages:
- Run: start agent run on this tab
- Analyze: run page threat analysis (DOM/NLP + optional LLM)
- Stop: stop current run
- Clear: clear panel output
If you don’t see the overlay:
- You’re likely on a restricted page (
chrome://*, Web Store, etc.) - Reload extension and refresh the page
main.py→ FastAPI serversrc/agent/*→ planner + action execution + CDP attachfirewall/*+analysers/*→ multi-layer threat analysis + risk scoringsrc/memory/sqlite_memory.py→ persistent memory (SQLite + FTS5)extension/→ MV3 extension (content script overlay + service worker proxy)
- macOS + Google Chrome installed
- Python 3.11+
- A Gemini key if you want the LLM firewall layer
python3 -m pip install -r config/requirements.txtThis project primarily uses System Chrome, but Playwright may still be used by some utilities/tests.
playwright installCreate a .env (or export env vars) for keys and tuning.
Minimum (LLM features):
GOOGLE_API_KEY=your_keyOptional knobs:
# Server
SERVER_PORT=8001
# Firewall
FIREWALL_LLM_THRESHOLD=0.4
# Memory
AGENT_MEMORY_DB=agent_memory.dbpython3 main.pyHealth check:
GET http://127.0.0.1:8001/api/v1/health
- Go to
chrome://extensions - Enable Developer mode
- Load unpacked → select the
extension/folder - Open any normal webpage → overlay appears top-right
Notes:
- The extension uses a MV3 service worker (
extension/background.js) to proxy requests to the local API. - If you change extension files, hit Reload in
chrome://extensions.
POST /api/v1/agent/run_on_active_tab
{
"task": "go to amazon and search for nothing phones",
"tabId": 123,
"tabUrl": "https://example.com",
"marker": "uuid",
"max_steps": 15
}GET /api/v1/task-status
POST /api/v1/stop-task
POST /api/v1/firewall/analyze_page
{
"page_content": "<html>…</html>",
"goal": "optional agent goal",
"tabUrl": "https://example.com",
"title": "Page title"
}The SecurityMediator runs a layered inspection:
- DOM Analyzer (fast): forms, scripts, redirects, obfuscation
- NLP Classifier (fast-ish): visible + hidden text signals
- LLM Reasoner (optional): used when risk crosses a threshold
- Risk Calculator: produces a final score + action
The response includes:
risk_score(0..1)action:ALLOW | CONFIRM | BLOCK- an explanation string
- a detailed breakdown
Set:
export FIREWALL_LLM_THRESHOLD=0.0(Requires GOOGLE_API_KEY.)
The agent stores lightweight “RAG-style” memories in agent_memory.db:
- step summaries (action + outcome)
- URL + title
- truncated page snapshots
- safety metadata (trusted / risk_score when available)
Retrieval is trust/risk-aware (prefers trusted + low-risk + same domain/task).
Configure DB location:
export AGENT_MEMORY_DB=/absolute/path/to/agent_memory.db- Must be a normal
http(s)page (notchrome://*, Web Store, etc.) - Reload extension in
chrome://extensions - Refresh the page
- Confirm server is up:
curl http://127.0.0.1:8001/api/v1/health
- Check Extension → Service worker console for logs
- Ensure
GOOGLE_API_KEY(orGEMINI_API_KEY) is set - Lower the threshold:
FIREWALL_LLM_THRESHOLD=0.0
extension/– Chrome extension (overlay UI + background proxy)src/agent/– agent runtime + CDP attach + safe execution loopfirewall/+analysers/– page analysis + LLM firewallsrc/memory/– SQLite memory (FTS5)scripts/run_dom_threat_check.py– CLI test harness for DOM threat analysis
Educational/research use. Only automate sites where you have authorization.