Page Agent

The In-Page GUI Agent That Controls Web Interfaces with Natural Language

alibaba/page-agent · 12.9k stars · TypeScript · MIT

agent37.club

The Browser Automation Problem

Current approaches have heavy dependencies

  • Browser extensions require install, permissions, and store approval
  • Python backends (Playwright, Selenium) need a server and headless browser
  • Vision-based agents require multimodal LLMs and screenshot processing
  • RPA tools are fragile, selector-based, and expensive

Core tension

The web page already knows its own structure. Why send screenshots to a vision model when the DOM is right there?

What Is Page Agent?

"Everything happens in your web page."

A pure JavaScript library that runs inside the page, reads the DOM as text, sends it to any LLM, and executes the returned actions directly. No extensions, no Python, no headless browsers.

Design philosophy

Client-side web enhancement, not server-side automation. Page Agent is designed to be embedded into products, not to scrape them from outside.

Architecture Overview

Monorepo with 8 packages

uiChat panel, human-in-the-loop UI
page-agentMain orchestrator, agentic loop
page-controllerDOM extraction + action execution
llmsOpenAI-compatible LLM interface
core + mcp + extensionShared utils, MCP protocol, Chrome ext

The Agent Loop

Observe → Think → Act → Repeat

1. DOM Extraction

page-controller traverses the live DOM, identifies interactive elements (buttons, inputs, links, selects), and produces a text representation with element indices.

2. LLM Planning

The text DOM + user instruction + action history are sent to the LLM. The model returns a structured action: which element index to interact with and how.

3. Action Execution

page-controller dispatches the action (click, type, scroll, select) on the real DOM element. The page updates.

4. Loop or Complete

The agent re-extracts the DOM, checks if the task is done, and either loops back to step 1 or returns the result.

DOM Extraction

Turning a web page into text an LLM can reason about

The page-controller package (derived from browser-use) walks the DOM tree and produces an indexed text map:

// Simplified output
[1] <button> Login </button>
[2] <input type="email" placeholder="Email">
[3] <input type="password">
[4] <a href="/forgot"> Forgot password? </a>
[5] <select> English | Chinese </select>

Why text, not vision?

  • Works with any text LLM
  • Much smaller payload than a screenshot
  • Faster round-trip times
  • No multimodal model needed
  • Precise element targeting via indices

Text DOM vs Vision Agents

A fundamental architecture choice

DimensionPage Agent (text DOM)Vision agents (screenshots)
Input size~2-5 KB text~200-500 KB image
Model requirementAny text LLMMultimodal (GPT-4V, etc.)
Latency per stepFast (small payload)Slow (image encoding)
Element precisionExact (DOM index)Approximate (x,y coords)
Dynamic contentReads live DOM statePoint-in-time snapshot
Canvas / imagesCannot "see" pixelsCan interpret visuals
Cost per stepLow (text tokens only)High (image tokens)

LLM Integration

Bring your own model

The llms package exposes an OpenAI-compatible interface. Any model that speaks the chat completions API works:

const agent = new PageAgent({
  // Alibaba's Qwen
  model: 'qwen3.5-plus',
  baseURL: 'https://dashscope...
    /compatible-mode/v1',
  apiKey: 'sk-...',
})

// Or use OpenAI, Anthropic, local models
const agent = new PageAgent({
  model: 'gpt-4o',
  baseURL: 'https://api.openai.com/v1',
  apiKey: 'sk-...',
})

Tested providers

  • Qwen 3.5 Plus (Alibaba DashScope)
  • OpenAI GPT-4o / GPT-4
  • Any OpenAI-compatible API
  • Local models via Ollama / LM Studio

Free testing API

A demo CDN build ships with a free testing API key for quick evaluation.

Installation & Setup

Three ways to get started

NPM (recommended)

npm install page-agent
import { PageAgent } from 'page-agent'

const agent = new PageAgent({
  model: 'qwen3.5-plus',
  baseURL: 'https://dashscope...',
  apiKey: 'YOUR_KEY',
  language: 'en-US',
})

await agent.execute(
  'Click the login button'
)

CDN (quick demo)

<!-- Global CDN -->
<script src="https://cdn.jsdelivr.net
  /npm/[email protected]/dist
  /iife/page-agent.demo.js"
  crossorigin>
</script>

<!-- China mirror -->
<script src="https://registry
  .npmmirror.com/page-agent
  /1.6.0/files/dist/iife
  /page-agent.demo.js">
</script>

Package: page-controller

The eyes and hands of the agent

This is the core package that bridges the gap between the DOM and the LLM. It handles two jobs:

DOM Extraction (eyes)

  • Traverses the live DOM tree
  • Filters to interactive elements only
  • Assigns stable numeric indices
  • Extracts text content, attributes, and element types
  • Produces a compact text representation

Action Execution (hands)

  • Click, type, scroll, select, hover
  • Targets elements by index from LLM output
  • Dispatches real DOM events
  • Waits for page updates before returning

Heritage

DOM processing components and prompts are derived from the browser-use project (MIT licensed), adapted for in-page execution rather than external control.

Package: llms

The model-agnostic communication layer

The llms package provides a unified interface for talking to any LLM that supports the OpenAI chat completions format.

What it does

  • Formats DOM text + user instructions into prompts
  • Maintains conversation history across loop iterations
  • Parses structured action responses from the model
  • Handles streaming and error recovery

Configuration

{
  model: 'model-name',
  baseURL: 'endpoint',
  apiKey: 'key',
  language: 'en-US',
}

Any OpenAI-compatible endpoint works. The model just needs to be good at structured output and instruction following.

Package: ui

Human-in-the-loop chat interface

Page Agent ships with a built-in chat panel that provides:

  • Natural language input for typing commands
  • Step-by-step feedback showing what the agent is doing
  • Confirmation prompts before destructive actions
  • Action history of all steps taken
  • Error display when actions fail

The UI is fully customizable and can be themed to match your product.

Human in the loop

Unlike fully autonomous agents, Page Agent's default UI shows each planned action and can require user approval. This is critical for production SaaS deployments where you cannot let an AI make unchecked changes.

MCP Integration

Model Context Protocol support (v1.6.0 beta)

The mcp package enables Page Agent to expose its capabilities as MCP tools, allowing external AI systems to control web pages through it.

  • Exposes execute as an MCP tool
  • Allows Claude Desktop, Cursor, and other MCP clients to use Page Agent
  • Bi-directional: Page Agent can also consume MCP servers for extended capabilities

Why this matters

MCP turns Page Agent from a standalone library into an interoperable tool in the broader AI ecosystem. An agent running in Claude Desktop could call Page Agent to interact with a web app as one step in a larger workflow.

Chrome Extension

Multi-page tasks across tabs

The core library works within a single page. For workflows that span multiple pages or tabs, the optional Chrome extension bridges the gap:

  • Tab orchestration -- navigate between pages
  • Cross-origin tasks -- work across different domains
  • Persistent context -- maintains task state across navigation
  • Background coordination -- extension coordinates multiple page-agent instances

Trade-off

The extension reintroduces the browser extension dependency that Page Agent otherwise avoids. It is optional and only needed for multi-page workflows.

Use Cases

Four target domains

SaaS AI Copilot

Embed Page Agent into your product to give users a natural language interface. "Show me last quarter's revenue chart" triggers navigation and data display without building custom NL commands.

Smart Form Filling

Complex ERP/CRM forms with dozens of fields. "Fill this purchase order with the data from the attached invoice" -- one sentence replaces 15 minutes of data entry.

Accessibility

Voice-controlled web interfaces for users who cannot use a mouse or keyboard. The agent translates spoken commands into precise page interactions.

Multi-Page Automation

With the Chrome extension: "Copy the tracking number from the shipping page and paste it into the customer's order in our CRM."

Page Agent vs browser-use

Same DNA, different execution environment

AspectPage Agentbrowser-use
RuntimeIn-browser JavaScriptPython + Playwright
Installationnpm install / CDN script tagpip install + browser binary
DOM accessDirect (same process)Remote (CDP / WebSocket)
Target use caseProduct integration (SaaS copilot)External automation / scraping
Multi-pageRequires Chrome extensionBuilt-in (controls browser)
Server neededNoYes (Python process)
Vision supportText-only DOMText + screenshot modes

Page Agent acknowledges browser-use as the source of its DOM processing components and prompts.

Technical Stack

Language breakdown and build system

TypeScript
81.2%
JavaScript
11.5%
CSS
5.9%
HTML
1.4%
  • Monorepo with 8 packages
  • IIFE build for CDN distribution
  • 784 commits, 24 releases
  • ~19 contributors
  • Latest: v1.6.0 (MCP beta, Mar 2026)

Distribution

Ships as both an npm package (ESM/CJS) and a single IIFE script for drop-in CDN usage. The IIFE build bundles all dependencies into one file.

Security Considerations

Running an LLM-controlled agent in the browser

Risks

  • API key exposure -- keys are in client-side JavaScript
  • Prompt injection -- malicious page content could hijack the agent
  • Unintended actions -- LLM might click "Delete" instead of "Save"
  • Data exfiltration -- agent reads the full DOM, including sensitive content

Mitigations

  • Human-in-the-loop UI for approval of actions
  • Proxy API keys through your backend
  • Scope the agent to specific page regions
  • Client-side only -- no data leaves except to the LLM endpoint

For production use, always proxy LLM calls through your backend to avoid exposing API keys in the browser.

Limitations

Where Page Agent falls short

Competitive Landscape

Where Page Agent sits in the browser agent ecosystem

ToolApproachRuntimeBest for
Page AgentIn-page text DOMBrowser JSSaaS copilots, embedding
browser-useExternal text DOMPythonAutomation, scraping
Anthropic CUAScreenshots + visionAPIGeneral computer use
LaVagueHybrid vision/DOMPythonWeb testing, QA
Playwright MCPProgrammatic controlNode.jsDeterministic automation
StagehandVision + DOMTypeScriptWeb agents, scraping

Page Agent's unique position: it is the only major agent that runs inside the page itself rather than controlling it from outside. This makes it ideal for product builders rather than automation engineers.

Key Takeaways

1. Page Agent proves that browser agents do not need screenshots, extensions, or Python. A text DOM + any LLM is sufficient for most web interactions.

2. The in-page architecture makes it uniquely suited for product integration (SaaS copilots, accessibility) rather than external scraping.

3. MCP support (v1.6.0) positions it as an interoperable tool in the AI ecosystem, not just a standalone library.

4. The text-only approach trades visual understanding for speed, cost, and model flexibility. The right choice depends on your use case.

Page Agent

In-page GUI agent for controlling web interfaces with natural language

github.com/alibaba/page-agent

12.9k stars · TypeScript · MIT License · v1.6.0

agent37.club