How raam751/agentx works
1. Project shape
- This is a Node.js browser-automation service with a live web dashboard.
- The backend orchestrates a Playwright-driven browser, an LLM decision layer, and a real-time UI over Socket.IO.
- It is packaged for Docker deployment and exposed on port 3000 locally / 7860 in the container setup.
2. Top-level runtime boundary
- server.js is the entry point and likely owns the Express HTTP server plus the Socket.IO channel.
- That server serves the static dashboard from public/ and also acts as the coordination hub for agent execution and telemetry.
3. Core automation pipeline
- The agent loop follows a tight cycle: capture screenshot, annotate interactive elements, ask the LLM what to do, execute the action in the browser, then verify the result.
- This makes the system fundamentally different from selector-driven scripts: decisions are based on annotated visual state rather than DOM selectors alone.
4. Browser control subsystem
- src/browser.js is the Playwright wrapper.
- It encapsulates browser/page management and is called by the agent for navigation, clicks, typing, scrolling, screenshots, and state checks.
- The README notes it is iframe-aware, which matters because the automation needs to work across embedded frames, not just the top document.
5. Vision/annotation subsystem
- src/annotator.js is responsible for extracting interactive elements from the current page and drawing numbered bounding boxes onto screenshots.
- That annotated image is the main input to the LLM, so the annotation layer is the bridge between raw browser state and model reasoning.
6. LLM decision layer
- src/llm.js abstracts over model providers and supports at least Groq and OpenAI.
- The architecture uses the LLM as a planner/selector: it interprets the screenshot plus task context and returns an action targeting an element number or a browser command.
- The provider abstraction is important because it keeps the agent logic independent from any one API vendor.
7. Agent orchestration and self-correction
- src/agent.js is the central control loop and owns step-by-step task execution.
- It is responsible for turning LLM output into browser actions, then checking whether the intended effect occurred.
- If verification fails, the agent feeds back failure context and retries, which is the system’s main resilience mechanism.
8. Logging and telemetry path
- src/logger.js emits structured runtime events and streams them to connected clients through Socket.IO.
- This creates a second output channel besides browser actions: human-readable reasoning, action logs, and progress updates for the dashboard.
9. Dashboard frontend
- public/index.html, public/styles.css, and public/app.js make up the monitoring UI.
- The frontend connects back to the Socket.IO server, receives live screenshots and logs, and presents the agent’s activity in real time.
- The dashboard is a consumer of backend events rather than the control plane itself.
10. State and artifacts
- The repo includes a screenshots/ output directory in the README flow, implying the system persists visual artifacts during execution.
- Those screenshots are important for debugging, replaying failures, and showing the agent’s current view in the UI.
11. Configuration and deployment boundaries
- Environment variables in .env.example control provider choice, API keys, headless mode, maximum steps, and server port.
- Dockerfile and the README’s SDK metadata indicate the project is intended to run as a containerized service, which is the main deployment unit.
12. Primary data flow for an architecture diagram
- User enters a natural-language task in the dashboard.
- The backend agent captures the current browser viewport via Playwright.
- The annotator overlays element numbers and passes that image to the LLM.
- The LLM returns an action decision.
- The browser wrapper executes the action.
- Verification checks success; failures loop back into another LLM-guided attempt.
- Throughout the loop, logger events stream to the frontend for live visibility.
Main entry points: agent.js Agent loop · server.js Server · browser.js Browser · app.js Client app
Components 11
Runtime
Server-side automation and coordination
- Server · Starts the app, serves the dashboard, and coordinates browser automation and live events.
server.js - Agent loop · Runs the stepwise capture, plan, act, verify cycle and handles retries on failure.
src/agent.js - Browser · Owns browser and page control for navigation, clicks, typing, scrolling, screenshots, and checks.
src/browser.js - Annotator · Finds interactive elements and draws numbered boxes onto screenshots for model input.
src/annotator.js - LLM · Abstracts model providers and turns task context plus annotated state into an action decision.
src/llm.js - Logger · Emits structured runtime events and forwards logs and progress to connected clients.
src/logger.js
Dashboard
Live monitoring frontend
- Dashboard · Browser-facing page that displays the agent’s live activity and task state.
public/index.html - Client app · Receives live updates, screenshots, and logs from the backend and renders them in the dashboard.
public/app.js - Styles · Presentation layer for the monitoring dashboard.
public/styles.css
Deployment
Container and environment boundaries
- Dockerfile · Defines the packaged runtime image and deployment container shape.
Dockerfile - Env config · Documents provider choice, API keys, headless mode, step limits, and port configuration.
.env.example
Connections 14
- Server → Dashboard: serves · Hosts the dashboard assets over HTTP.
- Server → Agent loop: starts · Creates and supervises the automation loop.
- Server → Logger: streams · Publishes runtime events to connected clients.
- Dashboard → Client app: loads · The page includes the client-side dashboard script.
- Client app → Server: connects · Subscribes to live updates through Socket.IO.
- Agent loop → Browser: controls · Uses the browser wrapper to operate the page.
- Agent loop → Annotator: captures · Requests annotated screenshots and interactive element maps.
- Agent loop → LLM: asks · Sends annotated state and task context for the next action.
- LLM → Agent loop: decides · Returns the action or browser command to execute.
- Annotator → Browser: reads state · Consumes screenshots and page content from the browser session.
- Browser → Agent loop: reports · Provides results, screenshots, and verification signals.
- Logger → Client app: updates · Feeds logs, progress, and visual artifacts to the UI.
- Dockerfile → Server: packages · Builds the service for container deployment.
- Env config → Server: configures · Supplies provider and runtime settings.