How aws/nova-act works
Overall Project Type and Purpose
• This as a Python SDK for browser automation and “actuation” of web browsing tasks.
• It is intended both as a developer tool (via scripting and interactive modes) and as an experimental agent framework where high-level natural language commands are broken down into discrete actions.
• The SDK integrates with Playwright for browser control and uses a modular internal design to manage commands, logging, and session management.
Main Components
• Client/Usage Interface: This is where developers write scripts (or interact via a Python shell) by importing NovaAct. It includes the sample scripts provided under the samples directory.
• SDK Core Library (src/nova_act):
• The top-level module (nova_act.py) that exposes the NovaAct class.
• The “impl” submodule contains key implementations for handling browser events, interactions with Playwright, and internal logic (e.g. backend, protocol handling, message encryption).
• “types” and “util” submodules provide contracts, error handling (schemas and Pydantic models) plus utility functions for logging, JSON validation, and terminal management.
• Artifacts (src/nova_act/artifacts): Contains browser extension resources (JavaScript, manifest file, static assets) that are deployed with the SDK to support browser instrumentation. This is especially used for the Chrome MV3 variant.
• Configuration & Build: pyproject.toml and requirements.txt manage dependencies and build configurations.
• Authentication & Logging: The SDK supports API key authentication (see the README instructions) and logs detailed act traces to help in debugging and performance monitoring.
• Parallel/Concurrent Control: Implementation details in the samples and “impl” indicate support for running multiple sessions concurrently (via thread pools) and handling independent browser contexts.
Relationships and Data Flow
• Client Code (user scripts or interactive sessions) calls NovaAct’s API (mainly the act() method).
• The NovaAct class routes these commands to internal “impl” modules. For example:
• The “backend.py” may coordinate complex workflow control.
• “protocol.py” and “window_messages.py” handle communications between the Python layer and the Playwright-driven browser.
• The logging and trace system should be indicated, showing that after each act(), a log file (HTML trace) is generated in a user-specified logs directory.
• API key authentication is a preliminary setup step that feeds into session initialization (configured via environment variable or directly in NovaAct’s constructor).
Important Architectural Patterns and Technologies
• Modular design: Separation into “impl”, “types”, and “util” directories suggests a clear separation of concerns.
• Command pattern: The act() method encapsulates a high-level command which then gets broken down into multiple lower-level browser actions.
• Parallel processing: Samples hint at running multiple NovaAct sessions concurrently―a microservice-like approach for parallel browser sessions.
• Use of external libraries: Playwright for browser automation and pydantic for defining and validating JSON schemas.
• Authentication and Environment configuration: via environment variables and configuration files.