How tutingjun/browser-use-acp works
Main Components
• Agent Module: Located in the “browser_use/agent” directory, this part encapsulates logic for interacting with LLMs and orchestrating browser actions. It includes submodules like the message manager (with service, tests, utils, and views), prompts, and system prompt files.
• Browser Module: Found in “browser_use/browser”, it is responsible for low-level browser control using tools like Playwright. It includes core functionality (e.g., browser.py and context.py) and its own test suite.
• Controller Module: In “browser_use/controller”, this module seems to offer a higher-level registry and additional control logic for coordinating between the agent and browser components.
• DOM Extraction/Processing: The “browser_use/dom” directory provides the logic for extracting and processing DOM information – including building a DOM tree, handling history, and exposing services and views.
• Telemetry & Logging: The “browser_use/telemetry” and “browser_use/logging_config.py” components track usage and provide essential logging support.
• Utilities: The “browser_use/utils.py” file hosts shared functionality across various modules.
• Documentation & Examples: Folders such as “docs” and “examples” illustrate deployment, UI integrations (e.g., with gradio and streamlit), and usage of features, clarifying how components interconnect.
Out Relationships and Interactions
• The Agent serves as the orchestrator that interprets tasks (using LLM integration like ChatOpenAI) and makes decisions on what browser actions to perform.
• Browser Module acts on those decisions by executing interactions modeled after UI behaviors (clicks, navigation, etc.). It is invoked by the Agent either directly or via a controller.
• The Controller provides an abstraction layer that can register components (actions) and manage their lifecycle and expose registry views for enhanced configurability.
• The DOM Module is used by both the Agent and Browser: it extracts information from the live browser DOM, processes page structures, and provides intermediate representations, which may then be used for decision making.
• Logging and Telemetry capture events from the above modules, ensuring observability and debugging support.
• External services such as Playwright (for browser automation) and third-party LLM APIs (e.g., OpenAI) are integrated into these modules.
• Tests and examples act as validation points and usage demonstrations for each module, ensuring that the overall system functions cohesively.
Architectural Patterns and Important Design Principles
• Modularity: The project is broken into clear modules (agent, browser, controller, DOM, telemetry) that encapsulate discrete responsibilities.
• Layered Interaction: The Agent layer abstracts high-level tasks while interfacing with lower-level browser control and DOM processing components.
• Testability: Each module includes dedicated testing suites (e.g., “tests/”, “agent/tests.py”, “dom/tests/”), reflecting a design that prioritizes robustness and maintainability.
• Extensibility: Examples and integration subdirectories (including custom functions and integrations with Discord and Slack) highlight that the system was designed with extensibility and plug-and-play enhancements in mind.