Design Racing
Labs Knowledge 中文
  1. MengPaw.Browser Development Documentation
  2. Introduction
  3. What Is MengPaw.Browser
  4. Why Do You Need It
  5. How to Read This Document
  6. Part 1 Quick Start — Controlling the Browser over the am Bridge
  7. 1. Prerequisites
  8. 2. Two-Step Invocation
  9. 3. Security Model
  10. 4. Operating After a Successful Connection
  11. Part 2 Starting from the Source — Directory Structure and Implementation
  12. 5. Repository and Build
  13. 6. Directory Structure (File Map)
  14. 7. Command-Surface Implementation
  15. 8. Invocation-Channel Implementation — the am Bridge ( RunCommandService )
  16. 9. Security Model
  17. 10. Storage and Screenshots
  18. 11. Testing
  19. 12. Development Conventions
Author: 小檬 XMeng · 墨迹 MojiPublished: Sep 10, 202612 min read

MengPaw.Browser Development Documentation

A standalone APK (an Android browser app) that ships with a built-in Playwright-style semantic command surface for semi-automatic control by AI Agents.
Doc version: v0.10.1 · 2026-09-10 · License: AGPL-3.0-or-later OR LicenseRef-Commercial
This document has two parts: Part 1 guides a Shell Agent through controlling the browser over the am bridge and starting to operate it;
Part 2 is aimed at developers and explains the directory structure and implementation.
Companion document: MengPaw_Browser_skills.md(the complete Agent operations manual: full command-surface table /
semi-automatic loop / forms / scraping / troubleshooting / Playwright comparison).


Introduction

What Is MengPaw.Browser

MengPaw.Browser (package name com.mengpaw.browser) is an Android browser APK that can be programmatically controlled by an AI Agent: a full WebView-based browser that humans can use directly, which also ships with a Playwright-style semantic command surface (page.* — 22 commands + browser.* — 21 commands), exposed to same-signature apps (MengPaw Shell being one of them) over a Termux-style am bridge (RunCommandService, protected by a signature permission).

In one sentence: a browser for humans, and a browser for Agents — an Agent can drive it just like Playwright to open pages, take full-page screenshots, click at coordinates, fill in forms, extract content, and manage tabs.

Why Do You Need It

How to Read This Document


Part 1 Quick Start — Controlling the Browser over the am Bridge

1. Prerequisites

2. Two-Step Invocation

# ① Wake the browser (when it is not running or was killed the am bridge is unreachable — it must be woken first)
am start -a com.mengpaw.action.OPEN_URL --es url "https://example.com"

# ② Execute a browser command: output lands in the public directory for the Shell to read back via agent.read / grep / head / tail
am startservice -n com.mengpaw.browser/.service.RunCommandService \
  --es com.mengpaw.browser.RUN_COMMAND_ARGUMENTS "-c,page.content --head 20" \
  --es com.mengpaw.browser.RUN_COMMAND_OUTPUT /storage/emulated/0/MengPaw/out.txt

If the browser process is killed the am bridge becomes unreachable; waking it again restores it. While it is not
running, calls report "browser not ready (open the MP browser first and retry)".

3. Security Model

Layer Protection
Caller authentication am bridge signature permission RUN_BROWSER_COMMAND; same-signature apps only
Command surface am bridge payload whitelist page.*/browser.*; arbitrary shell commands are rejected
Output path output files are confined to the public directory MengPaw/; system paths are forbidden
Storage MANAGE_EXTERNAL_STORAGE, permission dialog on first launch; after denial, every page.load prompts to re-grant

4. Operating After a Successful Connection

Once the connection is established, all of the browser's operating capabilities (the full 43-command table / semi-automatic loop / form automation / web scraping / troubleshooting quick reference / Playwright comparison) are covered by the companion document
MengPaw_Browser_skills.md, and this development document does not repeat them.


Part 2 Starting from the Source — Directory Structure and Implementation

5. Repository and Build

This repository is an independent browser project (rootProject MengPawBrowser, with :mengpaw-browser as its only module), split out of the main MengPaw repository as an APK artifact and now evolving independently. The shared foundation (micro-kernel / Android adaptation / design system) does not live here; it is consumed from main-repository artifacts via JitPack: com.github.WowBlueStudio.MengPaw:<module>:<tag>.

Coupling boundary with Shell / the main repository (only two items, everything else decoupled): ① the command manual
docs/MengPaw_Browser_skills.md must be synced to the Shell side; ② Android engineering notes are shared in the main
repository's docs/lessons.md. Decoupled: version line / releases / update path / roadmap / documentation ownership.
This project is a neutral tool — Shell using the Browser as a tool, or even checking for and installing its updates, is
Shell's own behaviour and does not conflict with this project's independent evolution; third-party shell-style software
can adapt by following the same command manual.

6. Directory Structure (File Map)

com.mengpaw.browser
├── BrowserActivity.kt         # APK entry: status bridge / permission guidance / am bridge shared instance
├── BrowserApp.kt              # Compose main UI (tabs / address bar / dialog state)
├── BrowserAppDialogs.kt       # Dialog rendering layer (state hoisted, parameters passed explicitly)
├── BrowserContentArea.kt      # Content area (NewTabPage / multi-tab WebView)
├── BrowserDarkMode.kt         # Dark mode injection
├── bridge/                    # BrowserBridge / BrowserScripts / FullPageScreenshotter
├── data/                      # BrowserPrefs / BrowserTypes / HistoryStore
├── plugin/                    # BuiltinBrowserPlugin + 4 command groups + BrowserCommandContext
├── service/                   # RunCommandService (am bridge) / GoogleTranslate
├── ui/                        # TopBar / Settings / Bookmarks / History / Tabs and other Compose UI
├── util/                      # AdBlocker / BrowserStorage / DownloadUtil / PdfUtil / SmartNavigate
└── web/                       # WebViewFactory / MdViewer* / PdfViewer*

Document viewers: .md goes through MdViewer* + assets/markdown_viewer (commonmark → HTML);
.pdf goes through PdfViewer* + assets/pdf_viewer (pdf.js 2.16 + CMaps, supporting zoom in/out and text selection,
for both remote .pdf URLs and local file/content VIEW intents). Both are near-full-screen WebView dialogs.

Key lifecycle events:

7. Command-Surface Implementation

Registration source: BuiltinBrowserPlugin.commands =
BrowserTabCommands + BrowserPageCommands + BrowserQueryCommands +
BrowserPlaywrightCommands. 43 commands in total (page.* 22 + browser.* 21).

All command implementations uniformly receive (List<String>, ExecutionContext) -> ExecutionResult, and access the
WebView bridge (BrowserBridge) / tab state / screenshotter through BrowserCommandContext.

8. Invocation-Channel Implementation — the am Bridge (RunCommandService)

action:  com.mengpaw.browser.RUN_COMMAND
extra:   com.mengpaw.browser.RUN_COMMAND_ARGUMENTS = "-c,<command-string>"
extra:   com.mengpaw.browser.RUN_COMMAND_OUTPUT    = <output-file-path, public directory>
extra:   com.mengpaw.browser.RUN_COMMAND_BACKGROUND = true
permission: com.mengpaw.permission.RUN_BROWSER_COMMAND (signature)
whitelist: only page.* / browser.* prefixes

RunCommandService performs quote-aware tokenization, executes commands through BuiltinBrowserPlugin.shared, and the
output is written to disk for the caller to read. If the browser is not running, it reports "browser not ready (open the MP browser first and retry)".

The 9880 HTTP bridge (McpHttpServer) and MCP open mode were retired and deleted under decision #7:
the browser side no longer has an HTTP bridge, token, GET /health or POST /mcp;
cleaning up the kernel-side documentation tables / prompt sections and mengpaw-connectors' browser-mcp-plugin
is left to the main repository (see browser-autopilot-plan.md §9).

9. Security Model

Layer Protection
am bridge signature permission RUN_BROWSER_COMMAND; same-signature apps only
Command surface am bridge payload whitelist page.*/browser.*; arbitrary shell is rejected
Output path am bridge output is restricted to the public directory MengPaw/
Storage MANAGE_EXTERNAL_STORAGE, permission dialog on first launch; after denial, every page.load prompts to re-grant

The 9880 bridge and open mode are retired (decision #7) — there is no longer a token or authentication-free channel,
and the attack surface converges on a single am bridge plus a signature permission.

10. Storage and Screenshots

11. Testing

src/test/kotlin/com/mengpaw/browser/:

Changes to the command surface / bridge / security logic must add matching unit tests; changes to core paths must keep
:mengpaw-browser:testDebugUnitTest fully green.

12. Development Conventions

AI