agent-in-a-browser
Verified Safeby tjfontaine
Overview
An in-browser, self-contained AI agent environment powered by WebAssembly (WASM) and WASI. It provides a full shell with development tools (TypeScript, Git, SQLite), a virtual file system (OPFS), and an agent layer for writing and executing code locally in a sandbox. The @tjfontaine/wasm-sqlite package specifically enables SQLite database operations within this browser sandbox.
Installation
npm run devEnvironment Variables
- PORT
- DEBUG
- WS_PORT
- HTTP_PORT
- CLOUDFLARE_ACCOUNT_ID
- CLOUDFLARE_API_TOKEN
- ANTHROPIC_API_KEY
- OPENAI_API_KEY
- GEMINI_API_KEY
Security Notes
The core functionality involves executing dynamic code (TypeScript/JavaScript) within a WASI sandbox in the browser, which is inherently high-risk if not properly isolated. The project mitigates this by leveraging browser-native security features: - **WASI Sandbox**: Provides a confined environment for code execution, aiming to prevent access to the host system. - **Origin Private File System (OPFS)**: Used for persistent storage, offering a sandboxed and isolated filesystem. - **Cross-Origin Isolation Headers**: `Cross-Origin-Opener-Policy` and `Cross-Origin-Embedder-Policy` are enforced via the `worker/index.js` to enable `SharedArrayBuffer` for synchronous WASM I/O, which is crucial for strong isolation in various browser environments. - **CORS Proxy Allowlist**: The `/cors-proxy` endpoint in `worker/index.js` explicitly whitelists domains like `api.githubcopilot.com`, `generativelanguage.googleapis.com`, `mcp.stripe.com`, and `github.com`. This helps control outbound requests originating from the main browser context. - **WASI HTTP Client**: WASM modules can make HTTP requests using the `wasi:http` API. While the `curl` command and LLM integrations use this, it means the WASM sandbox itself has network access, which could be a vector for data exfiltration if a malicious agent were to compromise the runtime. However, for an agent to function, such access is often necessary. - **Localhost MCP Bridge**: The `tools/mcp-bridge` provides a local WebSocket and HTTP server for integration with local tools like Claude Code. This is limited to `localhost` and is generally considered safe. Overall, significant effort has been made to secure a high-risk operation within browser sandboxing mechanisms. The residual risks are largely inherent to the nature of running arbitrary code, even within a carefully designed sandbox.
Similar Servers
mcp-chrome
Transforms the Chrome browser into an AI-controlled automation tool, enabling large language models to interact with web pages, analyze content, and manage browser functions.
hyper-mcp
A fast, secure Model Context Protocol (MCP) server that extends its capabilities through WebAssembly plugins, enabling AI agents to access tools, resources, and prompts.
wassette
A security-oriented runtime that runs WebAssembly Components via the Model Context Protocol (MCP), enabling AI agents to securely extend their capabilities with sandboxed tools.
Lynkr
Lynkr is an AI orchestration layer that acts as an LLM gateway, routing language model requests to various providers (Ollama, Databricks, OpenAI, etc.). It provides an OpenAI-compatible API and enables AI-driven coding tasks via a rich set of tools and a multi-agent framework, with a strong focus on security, performance, and token efficiency. It allows AI agents to interact with a defined workspace (reading/writing files, executing shell commands, performing Git operations) and leverages long-term memory and agent learning to enhance task execution.