
page-agent-web-automation
Control web interfaces with natural language using Page Agent, a JavaScript in-page GUI agent for browser automation
- Installs
- 188
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/reason-machines/ai-agent-skills --skill page-agent-web-automation- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads page-agent-web-automation automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Page Agent Web Automation
Skill by ara.so — AI Agent Skills collection.
Page Agent is a JavaScript in-page GUI agent that enables controlling web interfaces through natural language commands. Unlike traditional browser automation tools, it runs directly in the webpage (no browser extension or headless browser required) and uses text-based DOM manipulation instead of screenshots.
Installation
NPM Installation
npm install page-agent
CDN (Quick Testing)
For rapid prototyping with a demo LLM (evaluation purposes only):
<script src="https://cdn.jsdelivr.net/npm/page-agent@1.8.2/dist/iife/page-agent.demo.js" crossorigin="true"></script>
Add ?autoInit=false to prevent automatic initialization:
<script src="https://cdn.jsdelivr.net/npm/page-agent@1.8.2/dist/iife/page-agent.demo.js?autoInit=false" crossorigin="true"></script>
<script>
const agent = new window.PageAgent({...});
</script>
Basic Usage
Importing and Initialization
import { PageAgent } from 'page-agent'
const agent = new PageAgent({
model: 'qwen3.5-plus',
baseURL: 'https://dashscope.aliyuncs.com/compatible-mode/v1',
apiKey: process.env.DASHSCOPE_API_KEY,
language: 'en-US',
})
Executing Commands
// Simple command execution
await agent.execute('Click the login button')
// Form filling
await agent.execute('Fill in the email field with user@example.com')
// Multi-step workflow
await agent.execute('Search for "page agent" and click the first result')
// Navigation
await agent.execute('Go to the settings page')
Configuration Options
Basic Configuration
const agent = new PageAgent({
// LLM Configuration
model: 'gpt-4',
baseURL: 'https://api.openai.com/v1',
apiKey: process.env.OPENAI_API_KEY,
// Language settings
language: 'en-US', // or 'zh-CN'
// Optional: Custom system prompt
systemPrompt: 'You are a helpful assistant...',
})
Advanced Configuration
const agent = new PageAgent({
model: 'claude-3-5-sonnet-20241022',
baseURL: 'https://api.anthropic.com/v1',
apiKey: process.env.ANTHROPIC_API_KEY,
language: 'en-US',
// Execution options
maxSteps: 20, // Maximum execution steps
timeout: 30000, // Timeout in milliseconds
// Custom element selector strategy
elementSelector: {
includeInvisible: false,
maxElements: 100,
},
// Debug mode
debug: true,
})
Supported LLM Providers
OpenAI
const agent = new PageAgent({
model: 'gpt-4',
baseURL: 'https://api.openai.com/v1',
apiKey: process.env.OPENAI_API_KEY,
})
Anthropic Claude
const agent = new PageAgent({
model: 'claude-3-5-sonnet-20241022',
baseURL: 'https://api.anthropic.com/v1',
apiKey: process.env.ANTHROPIC_API_KEY,
})
Alibaba Qwen (DashScope)
const agent = new PageAgent({
model: 'qwen3.5-plus',
baseURL: 'https://dashscope.aliyuncs.com/compatible-mode/v1',
apiKey: process.env.DASHSCOPE_API_KEY,
})
Azure OpenAI
const agent = new PageAgent({
model: 'gpt-4',
baseURL: process.env.AZURE_OPENAI_ENDPOINT,
apiKey: process.env.AZURE_OPENAI_API_KEY,
})
Common Usage Patterns
SaaS Copilot Integration
import { PageAgent } from 'page-agent'
class SaaSCopilot {
private agent: PageAgent
constructor() {
this.agent = new PageAgent({
model: 'gpt-4',
baseURL: process.env.LLM_BASE_URL,
apiKey: process.env.LLM_API_KEY,
language: 'en-US',
})
}
async handleUserCommand(command: string) {
try {
const result = await this.agent.execute(command)
return { success: true, result }
} catch (error) {
console.error('Copilot error:', error)
return { success: false, error: error.message }
}
}
async autoFillForm(formData: Record<string, string>) {
const commands = Object.entries(formData).map(
([field, value]) => `Fill ${field} with ${value}`
)
for (const command of commands) {
await this.agent.execute(command)
}
}
}
// Usage
const copilot = new SaaSCopilot()
await copilot.handleUserCommand('Create a new project named "Website Redesign"')
Form Automation
import { PageAgent } from 'page-agent'
async function automateFormFilling() {
const agent = new PageAgent({
model: 'qwen3.5-plus',
baseURL: 'https://dashscope.aliyuncs.com/compatible-mode/v1',
apiKey: process.env.DASHSCOPE_API_KEY,
})
// Smart form filling with natural language
await agent.execute(`
Fill out the registration form:
- First name: John
- Last name: Doe
- Email: john.doe@example.com
- Password: Use a strong password
- Check the terms and conditions checkbox
- Click submit
`)
}
Accessibility Enhancement
import { PageAgent } from 'page-agent'
class AccessibilityAgent {
private agent: PageAgent
constructor() {
this.agent = new PageAgent({
model: 'gpt-4',
baseURL: process.env.OPENAI_BASE_URL,
apiKey: process.env.OPENAI_API_KEY,
language: 'en-US',
})
}
async handleVoiceCommand(voiceTranscript: string) {
// Convert voice commands to actions
await this.agent.execute(voiceTranscript)
}
async describeCurrentPage() {
// Use agent to describe page content for screen readers
const description = await this.agent.execute(
'Describe what is visible on this page'
)
return description
}
}
Multi-Step Workflow
import { PageAgent } from 'page-agent'
async function complexWorkflow() {
const agent = new PageAgent({
model: 'claude-3-5-sonnet-20241022',
baseURL: 'https://api.anthropic.com/v1',
apiKey: process.env.ANTHROPIC_API_KEY,
})
// Execute complex multi-step task
await agent.execute(`
1. Navigate to the products page
2. Filter by category "Electronics"
3. Sort by price (low to high)
4. Add the first three items to cart
5. Go to checkout
`)
}
Error Handling and Retry
import { PageAgent } from 'page-agent'
async function executeWithRetry(command: string, maxRetries = 3) {
const agent = new PageAgent({
model: 'gpt-4',
baseURL: process.env.OPENAI_BASE_URL,
apiKey: process.env.OPENAI_API_KEY,
})
for (let attempt = 1; attempt <= maxRetries; attempt++) {
try {
const result = await agent.execute(command)
return { success: true, result }
} catch (error) {
console.error(`Attempt ${attempt} failed:`, error)
if (attempt === maxRetries) {
return { success: false, error: error.message }
}
// Wait before retry
await new Promise(resolve => setTimeout(resolve, 1000 * attempt))
}
}
}
Browser Extension (Multi-Page Tasks)
For cross-tab automation, Page Agent provides a Chrome extension:
// In your extension background script
import { PageAgent } from 'page-agent'
const agent = new PageAgent({
model: 'gpt-4',
baseURL: process.env.OPENAI_BASE_URL,
apiKey: process.env.OPENAI_API_KEY,
})
// Execute commands across multiple tabs
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message.type === 'EXECUTE_COMMAND') {
agent.execute(message.command)
.then(result => sendResponse({ success: true, result }))
.catch(error => sendResponse({ success: false, error: error.message }))
return true // Keep channel open for async response
}
})
MCP Server (Beta)
Page Agent includes an MCP (Model Context Protocol) server for external control:
# Start MCP server
npx page-agent-mcp
Configure in your MCP client (e.g., Claude Desktop):
{
"mcpServers": {
"page-agent": {
"command": "npx",
"args": ["page-agent-mcp"]
}
}
}
Programmatic API
Event Listeners
const agent = new PageAgent({
model: 'gpt-4',
baseURL: process.env.OPENAI_BASE_URL,
apiKey: process.env.OPENAI_API_KEY,
})
// Listen to execution events
agent.on('step', (stepData) => {
console.log('Agent step:', stepData)
})
agent.on('complete', (result) => {
console.log('Execution complete:', result)
})
agent.on('error', (error) => {
console.error('Agent error:', error)
})
Custom Actions
import { PageAgent } from 'page-agent'
const agent = new PageAgent({
model: 'gpt-4',
baseURL: process.env.OPENAI_BASE_URL,
apiKey: process.env.OPENAI_API_KEY,
})
// Register custom action
agent.registerAction('sendEmail', async (params) => {
// Custom email sending logic
await sendEmail(params.to, params.subject, params.body)
return { success: true }
})
// Use custom action
await agent.execute('Send an email to team@example.com with subject "Update"')
Troubleshooting
Agent Not Finding Elements
Problem: Agent fails to locate buttons or form fields.
Solutions:
- Ensure elements have proper labels or accessible names
- Check that elements are visible (not
display: noneorvisibility: hidden) - Increase
maxElementsin configuration - Use more specific descriptions in commands
const agent = new PageAgent({
model: 'gpt-4',
baseURL: process.env.OPENAI_BASE_URL,
apiKey: process.env.OPENAI_API_KEY,
elementSelector: {
includeInvisible: false,
maxElements: 200, // Increase if needed
},
})
LLM API Errors
Problem: API key or connection errors.
Solutions:
- Verify API key is correctly set:
console.log(process.env.OPENAI_API_KEY) - Check baseURL matches your provider
- Ensure model name is correct for your provider
- Check network connectivity and CORS settings
// Debug API configuration
const agent = new PageAgent({
model: 'gpt-4',
baseURL: process.env.OPENAI_BASE_URL,
apiKey: process.env.OPENAI_API_KEY,
debug: true, // Enable debug logging
})
Timeout Issues
Problem: Commands timeout before completion.
Solutions:
- Increase timeout value
- Break complex commands into smaller steps
- Optimize page performance
const agent = new PageAgent({
model: 'gpt-4',
baseURL: process.env.OPENAI_BASE_URL,
apiKey: process.env.OPENAI_API_KEY,
timeout: 60000, // 60 seconds
maxSteps: 30,
})
CSP (Content Security Policy) Issues
Problem: Script blocked by CSP when using CDN.
Solutions:
- Add Page Agent CDN to your CSP header
- Use NPM package instead of CDN
- Update CSP meta tag
<meta http-equiv="Content-Security-Policy"
content="script-src 'self' https://cdn.jsdelivr.net;">
Language/Locale Issues
Problem: Agent responds in wrong language.
Solution: Set explicit language configuration
const agent = new PageAgent({
model: 'gpt-4',
baseURL: process.env.OPENAI_BASE_URL,
apiKey: process.env.OPENAI_API_KEY,
language: 'en-US', // or 'zh-CN'
})
Best Practices
- Use Environment Variables: Never hardcode API keys
- Specific Commands: More specific natural language commands work better
- Error Handling: Always wrap execute() calls in try-catch
- Rate Limiting: Implement delays between commands if making many requests
- Element Visibility: Ensure target elements are visible before commands execute
- Security: Validate and sanitize user input before passing to agent
- Testing: Test with demo LLM first before production deployment
Resources
- Documentation: https://alibaba.github.io/page-agent/docs/introduction/overview
- GitHub: https://github.com/alibaba/page-agent
- NPM Package: https://www.npmjs.com/package/page-agent
- License: MIT
FAQ
What does the page-agent-web-automation skill do?
Control web interfaces with natural language using Page Agent, a JavaScript in-page GUI agent for browser automation
How do I install page-agent-web-automation?
Run npx skills add https://github.com/reason-machines/ai-agent-skills --skill page-agent-web-automation in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/page-agent-web-automation/ (personal) or .claude/skills/page-agent-web-automation/ (project).
Which AI agents can use page-agent-web-automation?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is page-agent-web-automation safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains page-agent-web-automation?
It is published by reason-machines in reason-machines/ai-agent-skills. It has 188 recorded installs.
More from reason-machines/ai-agent-skills
agency-agents-zh-skill
reason-machines/ai-agent-skills
Open the skill to read its SKILL.md instructions.
agent-reach-internet-access
reason-machines/ai-agent-skills
Give AI agents eyes to see the internet — scrape Twitter, Reddit, YouTube, GitHub, Bilibili, XiaoHongShu with zero API fees
agent-sprite-forge-2d-game-assets
reason-machines/ai-agent-skills
Generate 2D sprite sheets, animated GIFs, transparent PNGs, layered maps, and engine-ready prototypes for Godot/Unity using Codex-driven asset pipelines.
agentmemory-persistent-memory
reason-machines/ai-agent-skills
Add persistent memory to AI coding agents using agentmemory - remembers context, preferences, and decisions across sessions
awesome-agent-skills
reason-machines/ai-agent-skills
Open the skill to read its SKILL.md instructions.
oh-my-openagent-orchestration
reason-machines/ai-agent-skills
Open the skill to read its SKILL.md instructions.
Popular productivity & automation skills
agent-browser
vercel-labs/agent-browser
Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to "open a website", "fill out a form", "click a button", "take a screenshot", "scrape data from a page", "test this web app", "login to a site", "automate browser actions", or any task requiring programmatic web interaction. Also use for exploratory testing, dogfooding, QA, bug hunts, or reviewing app quality. Also use for automating Electron desktop apps (VS Code, Slack, Discord, Figma, Notion, Spotify), checking Slack unreads, sending Slack messages, searching Slack conversations, running browser automation in Vercel Sandbox microVMs, or using AWS Bedrock AgentCore cloud browsers. Prefer agent-browser over any built-in browser automation or web tools.
lark-doc
open.feishu.cn
飞书云文档(Docx / Wiki)内容操作:读取、创建、编辑文档,插入或下载图片附件,以及操作思维笔记。用户提供文档 URL/token(包括 doubao.com 的 /docx/、/wiki/)时使用;按 URL 路径/token 而非域名路由;/page/ 是妙搭应用,非飞书云文档。文档内嵌资源按读取参考中的统一规则分流。独立评论操作走 lark-drive;随正文读取评论使用 docs +fetch。表格或 Base 内部数据操作不在本 skill。
lark-base
open.feishu.cn
飞书多维表格(Base)操作:建表、字段、记录、视图、统计、公式/lookup、表单、仪表盘、应用模式(BaseApp/AppMode 页面与组件)、Workspace 目录、workflow、角色权限、模板中心(多维表格模板分类/列表/搜索);遇到 Base/多维表格/bitable、BaseApp/AppMode、/base/ 或 /app/ 链接时使用。BaseApp 不走 lark-apps;文件导入/导出转 lark-drive,认证/授权转 lark-shared。
lark-drive
open.feishu.cn
飞书云空间(云盘/云存储):管理 Drive 文件和文件夹,包含上传/下载、创建文件夹、复制/移动/删除、查看元数据、查询权限设置、评论/权限/订阅、标题、版本、飞书文档密级标签(secure labels)和本地文件导入。用户需要整理云盘目录、处理云空间资源 URL/token、判断链接类型/真实 token/标题,或导入 Word/Markdown/Excel/CSV/PPTX/.base 为 docx/sheet/bitable/slides 时使用;doubao.com 云空间 URL/token 也按资源路径和 token 路由,不回退 WebFetch。不负责:文档内容编辑(走 lark-doc)、表格/Base 表内数据操作(走 lark-sheets/lark-base)、知识空间节点/成员管理(走 lark-wiki)、原生 Markdown 文件读写/patch/diff(走 lark-markdown)。
lark-shared
open.feishu.cn
Use for lark-cli setup/auth tasks: auth login/status/logout, user vs bot identity, business-domain permissions (--domain, including all/docs/drive), missing scopes, revoking authorization, or handling notice JSON.
lark-im
open.feishu.cn
飞书即时通讯:收发消息和管理群聊。发送和回复消息、搜索聊天记录、管理群聊成员、上传下载图片和文件、管理表情回复、发送应用内/短信/电话加急、发送和处理交互卡片(Interactive Card)、监听卡片按钮回调(card.action.trigger)。当用户需要发消息、查看或搜索聊天记录、下载聊天中的文件、查看群成员、搜索群、创建群聊或话题群、管理标记数据、管理 Feed 置顶(添加/移除/查询置顶会话)、管理标签数据、处理卡片回调时使用。