# Web Agent Proxy (WAP) ![Build Status](https://img.shields.io/badge/build-passing-brightgreen.svg) ![Tests](https://img.shields.io/badge/tests-119%20passed-blue.svg) ![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg) ![Node Version](https://img.shields.io/badge/node-%3E%3D18-green.svg) ![Security](https://img.shields.io/badge/E2EE-AES--256--GCM-purple.svg) Web Agent Proxy (WAP) gives AI agents reliable, consent-based web access through real human browser sessions without triggering anti-bot hurdles or leaking sensitive payload data. By decoupling AI agent orchestration from real-browser execution with zero-knowledge AES-256-GCM End-to-End Encryption (E2EE), your agents can scrape, screenshot, and automate real web pages while intermediate servers remain completely blind to target URLs, headers, and content. ![Web Agent Proxy Overview](wap_thumbnail.png) --- ## โšก Instant One-Command Setup Get the full Web Agent Proxy stack (Bridge Server, Playwright Browser Runner, and Interactive React Dashboard) up and running in seconds. ### Option A: Local Dev Launcher (Node.js) ```bash git clone https://github.com/52191314/Web-Agent-Proxy-SDK.git cd Web-Agent-Proxy-SDK # Install dependencies and start all services with pre-flight health checks npm install npm run build npm run start:all ``` `npm run start:all` executes an interactive environment validator (`scripts/dev-launcher.js`) that automatically checks Node.js version ($\ge 18$), verifies TCP port availability (`8080` & `5173`), and launches all services with unified color-coded logging. ### Option B: One-Command Containerized Setup (Docker) ```bash # Spin up Bridge Server + Browser Runner in isolated containers docker compose up --build -d ``` Access the **Interactive Dashboard & Diagnostic Workbench** at `http://localhost:8080`. --- ## ๐Ÿ’ก The Problem Web Agent Proxy Solves AI agents frequently encounter critical obstacles when accessing the web: - **Headless Detection & Blockers**: Traditional headless scrapers fail Cloudflare Turnstile, hCaptcha, and anti-bot checks. - **Privacy & Security Risks**: Routing AI agent traffic through third-party proxy services exposes user session cookies, credentials, and sensitive page data. - **Fragile Infrastructure**: Managing headless browser instances directly inside agent worker nodes consumes excessive CPU/RAM and leads to memory leaks. **Web Agent Proxy solves this by acting as an E2EE relay layer**: 1. **Consent-Based Browser Runners**: Routes requests through user-controlled browser instances that carry legitimate session cookies and profiles (`.wap-profiles`). 2. **Zero-Knowledge Blind Relay**: Client-side AES-256-GCM encryption ensures target URLs, request headers, and scraped response contents are encrypted *before* leaving the agent SDK and decrypted *only* inside the browser runner. The bridge server never sees plaintext payloads. 3. **Self-Healing & Load Balancing**: Intelligent rotation (`round-robin`, `least-connections`), automatic retry logic, circuit breakers, and sticky sessions keep agent workflows resilient. --- ## ๐Ÿ—๏ธ Architecture & Component Overview Web Agent Proxy is organized as an `npm` workspace monorepo comprising six packages: 1. **JS / TS SDK ([`packages/sdk-js`](./packages/sdk-js))**: Client library (`@web-agent-proxy/sdk-js`) for Node.js and TypeScript agents. Features built-in AES-256-GCM encryption, structured error codes, self-healing retries, and LangChain integration tools. 2. **Python SDK ([`packages/sdk-python`](./packages/sdk-python))**: Python client (`web-agent-proxy`) supporting Python AI frameworks (LangChain, LlamaIndex) with AES-256-GCM encryption and custom error exceptions. 3. **Bridge Server ([`packages/bridge-server`](./packages/bridge-server))**: High-throughput Express + WebSocket orchestration server listening on port `8080`. Manages runner queues, rotation policies, API key authentication, and blind E2EE relaying. 4. **Browser Runner ([`packages/simulator`](./packages/simulator))**: Playwright Chromium client executing web automation requests inside real browser contexts with session profile persistence (`.wap-profiles`). 5. **Dashboard UI ([`packages/dashboard`](./packages/dashboard))**: React 19 + Vite web monitoring application. Features real-time runner status indicators, WebSocket latency monitoring, and an interactive **Test Request Generator**. 6. **MCP Server ([`packages/mcp-server`](./packages/mcp-server))**: Model Context Protocol server (`@web-agent-proxy/mcp-server`) exposing WAP to any MCP-compatible agent host via five tools: `wap_scrape`, `wap_screenshot`, `wap_markdown`, `wap_interact`, and `wap_list_browsers`. --- ## ๐Ÿ”„ Conceptual Data Flow 1. **Client Encryption**: The AI Agent calls `proxy.scrape()`. The SDK encrypts target URL, headers, and cookies with AES-256-GCM using your private passphrase. 2. **Blind Relay**: The Bridge Server authenticates the request and dispatches the opaque payload over WebSocket to an available browser runner without decrypting it. 3. **Browser Execution**: The Playwright Browser Runner decrypts the payload, executes page actions (or handles anti-bot challenges), captures Markdown/HTML/Screenshots, and encrypts the result. 4. **Decrypted Result**: The SDK receives the encrypted HTTP response, decrypts it locally, and passes clean content back to your AI agent logic. --- ## ๐Ÿ“ฆ Runnable SDK Quickstart Snippets > **โš ๏ธ Install from source for these snippets.** This repository is at **`1.1.0`**, but the latest packages published to npm and PyPI are still **`1.0.0`**. The `1.0.0` releases ship only `scrape()` / `captureScreenshot()` and do **not** export the structured error classes (`WAPError` and friends), `scrapeMarkdown()` / `scrape_markdown()`, `interact()`, or the framework adapters. The snippets below therefore **require 1.1.0** and will fail against a plain `npm install @web-agent-proxy/sdk-js` or `pip install web-agent-proxy`. > > Until `1.1.0` is released, install from a repository checkout โ€” see the [Quickstart Guide](./docs/quickstart.md#running-your-first-sdk-request). Per-version API availability is documented in the [JS SDK Reference](./docs/sdk-js.md) and [Python SDK Reference](./docs/sdk-python.md). ### JavaScript / TypeScript SDK (`@web-agent-proxy/sdk-js`) ```typescript import { WebAgentProxyClient, WAPError } from "@web-agent-proxy/sdk-js"; async function main() { const proxy = new WebAgentProxyClient({ bridgeUrl: "http://localhost:8080", encryptionKey: "my-private-e2ee-passphrase", // Enables zero-knowledge AES-256-GCM E2EE maxRetries: 3, }); try { // 1. Scrape clean Markdown for LLM consumption const markdown = await proxy.scrapeMarkdown("https://example.com"); console.log("Markdown preview:\n", markdown.slice(0, 200)); // 2. Capture full-page screenshot const screenshotDataUri = await proxy.captureScreenshot("https://example.com"); console.log("Screenshot URI generated."); } catch (error) { if (error instanceof WAPError) { console.error(`[${error.code}] ${error.message}`); console.error("Troubleshooting advice:", error.troubleshootingAdvice); } } } main(); ``` ### Python SDK (`web-agent-proxy`) ```python from web_agent_proxy import WebAgentProxyClient, WAPError def main(): proxy = WebAgentProxyClient( bridge_url="http://localhost:8080", encryption_key="my-private-e2ee-passphrase", max_retries=3, ) try: # Scrape HTML content with zero-knowledge privacy html = proxy.scrape("https://example.com") print("Scraped HTML length:", len(html)) except WAPError as e: print(f"[{e.code}] {e.message}") print("Troubleshooting advice:", e.troubleshooting_advice) if __name__ == "__main__": main() ``` --- ## ๐Ÿ“š Complete Documentation Index For detailed guides, API reference, and configuration specs, check the `/docs` directory: - ๐Ÿš€ [Quickstart Guide](./docs/quickstart.md): Detailed installation for Node.js and Python environments. - ๐Ÿ“ [Architecture & Data Flow](./docs/architecture.md): Sequence diagrams and system design. - ๐Ÿ” [End-to-End Encryption Guide](./docs/e2ee-guide.md): AES-256-GCM zero-knowledge security spec. - โš™๏ธ [Configuration Reference](./docs/configuration.md): Environment variables, ports, and SDK client options. - ๐Ÿ› ๏ธ [Troubleshooting Guide](./docs/troubleshooting.md): Error codes, diagnostic checks, and common resolutions. - ๐Ÿ“˜ [JS SDK Reference](./docs/sdk-js.md) & [Python SDK Reference](./docs/sdk-python.md) --- ## ๐Ÿงช Verification & Testing Commands We maintain a strict 100% passing test harness across all monorepo workspaces: ```bash # Build all TypeScript workspace packages npm run build # Run automated unit and integration tests (119+ tests) npm test # Run Python SDK tests python -m unittest discover -s packages/sdk-python/tests ``` --- ## ๐Ÿค Contributing & Community Ecosystem We welcome contributions from the developer and AI agent community! - **Getting Started**: Check out our [CONTRIBUTING.md](./CONTRIBUTING.md) guide for setup and workflow guidelines. - **Code of Conduct**: Please review our [CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md). - **Good First Issues**: Look out for issues tagged `good first issue` or `help wanted` in our issue tracker. - **Awesome Ecosystem**: Web Agent Proxy is designed to integrate seamlessly into awesome AI agent frameworks (LangChain, LlamaIndex, AutoGen, CrewAI). If you are featuring WAP in `awesome-ai-agents`, `awesome-selfhosted`, or `awesome-playwright` lists, feel free to open a PR! --- ## ๐Ÿ“„ License MIT License. See [LICENSE](./LICENSE) for details.