agent-browser-guard
v1.0.0
Published
Zero-dependency DOM firewall & risk interceptor for autonomous browser agents (Playwright, Puppeteer, Computer Use). Blocks accidental payments, deletions, and irreversible transactions.
Maintainers
Readme
agent-browser-guard
Zero-dependency DOM firewall & risk interceptor for autonomous browser agents (Playwright, Puppeteer, Anthropic Computer Use, Browser Use). Blocks accidental payments, deletions, and irreversible transactions.
Why agent-browser-guard?
When autonomous AI browser agents browse web apps, dashboards, or SaaS consoles, they risk clicking irreversible buttons:
- Financial Risk: Clicking "Pay Now", "Upgrade to Enterprise", "Charge Credit Card", "Subscribe".
- Destructive Risk: Clicking "Delete Project", "Drop Database", "Cancel Membership", "Wipe Logs".
- Privilege Risk: Transferring organization ownership or creating admin API tokens.
agent-browser-guard acts as a real-time DOM firewall:
- Semantic Risk Classifier: Intercepts element text, ARIA attributes, classes, and form action URLs before clicks execute.
- Client-Side Injection: 1-line script injection into Playwright / Puppeteer pages.
- Zero External Dependencies: Pure regex heuristics, <8KB unpacked, 0.1ms evaluation.
- Dual CLI & MCP: Evaluates actions via CLI or directly inside Claude Code, Cursor, and Antigravity.
1. Quick Start (CLI)
# Check if clicking a button is safe or dangerous
npx agent-browser-guard check --text "지금 결제하기"
# ❌ BLOCKED: Financial transaction or payment action
npx agent-browser-guard check --text "Delete project permanently"
# ❌ BLOCKED: Irreversible destruction action
npx agent-browser-guard check --text "View Analytics Dashboard"
# ✅ SAFE2. Playwright / Puppeteer Integration
Inject the guardrail into your browser agent workflow in 3 lines:
import { chromium } from 'playwright';
import { getBrowserInjectionSnippet } from 'agent-browser-guard';
const browser = await chromium.launch();
const page = await browser.newPage();
// Inject real-time DOM firewall before page loads
await page.addInitScript(getBrowserInjectionSnippet());
await page.goto('https://app.example.com');
// If the agent tries to click a payment or deletion button,
// the browser event listener automatically halts the event (preventDefault)
// and sets window.__AGENT_GUARD_INTERCEPTED__!3. Programmatic Usage (Node.js / TypeScript)
import { evaluateAction } from 'agent-browser-guard';
const verdict = evaluateAction({
actionType: 'click',
target: {
text: 'Confirm $490 Subscription',
href: '/api/billing/subscribe',
},
});
if (!verdict.allowed) {
console.error(`Action blocked! Reason: ${verdict.reason}`);
// Request human confirmation before proceeding
}4. MCP Server Configuration
Add browser-guard-mcp to your MCP configuration (~/.claude/settings.json, Cursor MCP settings, or Antigravity config):
{
"mcpServers": {
"browser-guard": {
"command": "npx",
"args": ["-y", "agent-browser-guard"]
}
}
}Available Tools:
evaluate_browser_action: Evaluates element text/URL before clicking.get_injection_snippet: Returns client-side injection script for browser runtimes.
License
MIT © OIYO Lab
