How pas-mllr/openai-cua-sample-app works
Main Components
• CLI / Entry Point: Represented by the “cli.py” (and “main.py”/“simple_cua_loop.py”) which initializes the application and parses command-line arguments.
• Agent Module: The “agent/agent.py” encapsulates the main agent loop (e.g., run_full_turn()) that interacts with the OpenAI API and processes responses.
• Computer Interface & Implementations: The “computers/” directory implements a Computer interface (in “computers/computer.py”) and provides different environment implementations (e.g., “local_playwright.py”, “docker.py”, “browserbase.py”, “scrapybara.py”). These components are responsible for executing the received actions.
• External Dependencies: Include external services and tools such as the OpenAI API (for both responses and function calling), Playwright (for browser control), and Docker (for containerized environments).
• Examples: The “examples/” folder can be indicated as sample usage scenarios that show how one might run experiments or further test the core logic.
Relationships and Interactions
• The CLI serves as the starting point where a user selects a “Computer” environment (by passing options like “local-playwright”, “docker”, etc.).
• The CLI then instantiates the Agent. The Agent is responsible for continuously processing inputs and orchestrating the execution flow.
• The Agent calls the chosen “Computer” implementation (via the Computer interface) to execute actions such as clicks, typing, and so on.
• A feedback loop exists where the Computer captures the outcome (e.g., screenshots) and returns the state back to the Agent. This agent–computer loop continues until the session ends.
Architectural Patterns and Design Principles
• Modular Design: The separation between agent logic and computer abstractions allows for independent development/testing of each Computer environment.
• Interface Abstraction: The “Computer” interface allows adding new implementations without changing core agent logic.
• Extensibility: The design supports plug-and-play “Computer” environments (as shown by the variety in the “computers” directory).
• CLI-Driven Configuration: The core configuration and operation are driven by command-line inputs and environmental settings (e.g., via .env, Dockerfile).
Technologies, Frameworks, and Libraries
• Python as the core language.
• Playwright (in “local_playwright.py”) for controlling local browsers.
• Docker support provided by the “Dockerfile” and the “docker.py” implementation.
• External Computer services such as Browserbase and Scrapybara, which are integrated via API keys (referenced in the .env file).
• OpenAI API: The responses and function calling integrations form a critical dependency for the agent’s behavior.