Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
H

HyperAgent

> AI 编程
Open source

AI Browser Automation

1.5K stars0 likes0 views
WebsiteGitHub

About

AI Browser Automation

Overview

Hyperagent is Playwright supercharged with AI. No more brittle scripts, just powerful natural language commands. Just looking for scalable headless browsers or scraping infra? Go to Hyperbrowser to get started for free!

View HyperAgent docs here: https://www.hyperbrowser.ai/docs/hyperagent/introduction

Features

  • AI Commands: Simple APIs like page.ai(), page.extract() and executeTask() for any AI automation
  • ⚡ Fallback to Regular Playwright: Use regular Playwright when AI isn't needed
  • Stealth Mode – Avoid detection with built-in anti-bot patches
  • ☁️ Cloud Ready – Instantly scale to hundreds of sessions via Hyperbrowser
  • MCP Client – Connect to tools like Composio for full workflows (e.g. writing web data to Google Sheets)
  • Action Caching – Record and replay workflows deterministically without LLM calls

Quick Start

Installation

bash
# Using npm
npm install @hyperbrowser/agent

# Using yarn
yarn add @hyperbrowser/agent

CLI

bash
$ npx @hyperbrowser/agent -c "Find a route from Miami to New Orleans, and provide the detailed route information."

The CLI supports options for debugging or using hyperbrowser instead of a local browser

bash
-d, --debug                       Enable debug mode
-c, --command <task description>  Command to run
--hyperbrowser                    Use Hyperbrowser for the browser provider

Library

…

Two Modes of Operation

HyperAgent provides two complementary APIs optimized for different use cases:

page.perform() - Single Granular Actions

page.aiAction() is deprecated and remains available as an alias; prefer page.perform() going forward.

Best for: Single, specific actions like "click login", "fill email with [email protected]"

Advantages:

  • ⚡ Fast - Uses accessibility tree (no screenshots)
  • Cheap - Single LLM call per action
  • Reliable - Direct element finding and execution
  • Efficient - Text-based DOM analysis with automatic ad-frame filtering

Example:

typescript
const page = await agent.newPage();
await page.goto("https://example.com/login");

// Fast, reliable single actions
await page.perform("fill email with [email protected]");
await page.perform("fill password with mypassword");
await page.perform("click the login button");

page.ai() - Complex Multi-Step Tasks

Best for: Complex workflows requiring multiple steps and visual context

Advantages:

  • ️ Visual Understanding - Can use screenshots with element overlays
  • Complex Tasks - Handles multi-step workflows automatically
  • Context-Aware - Better at understanding page layout and relationships
  • Adaptive - Can adjust strategy based on page state

Parameters:

  • useDomCache (boolean): Reuse DOM snapshots for speed
  • enableVisualMode (boolean): Enable screenshots and overlays (default: false)

Example:

typescript
const page = await agent.newPage();
await page.goto("https://flights.google.com");

// Complex task with multiple steps handled automatically
await page.ai("search for flights from Miami to New Orleans on July 16", {
  useDomCache: true,
});

Mix and Match

Combine both APIs for optimal performance:

typescript
// Use perform for fast, reliable individual actions
await page.perform("click the search button");
await page.perform("type laptop into search");

// Use ai() for complex, multi-step workflows
await page.ai("filter results by price under $1000 and sort by rating");

// Extract structured data
const products = await page.extract(
  "get the top 5 products",
  z.object({
    products: z.array(z.object({ name: z.string(), price: z.number() }))
  })
);

☁️ Cloud

You can scale HyperAgent with cloud headless browsers using Hyperbrowser

  1. Get a free api key from Hyperbrowser
  2. Add it to your env as HYPERBROWSER_API_KEY
  3. Set your browserProvider to "Hyperbrowser"
typescript
const agent = new HyperAgent({
  browserProvider: "Hyperbrowser",
});

const response = await agent.executeTask(
  "Go to hackernews, and list me the 5 most recent article titles"
);

console.log(response);
await agent.closeAgent();

Usage Guide

Multi-Page Management

…

Customization

Output Schema Definition

HyperAgent can extract data in a specified schema. The schema can be passed in at a per-task level

typescript
import { z } from "zod";

const agent = new HyperAgent();
const agentResponse = await agent.executeTask(
  "Navigate to imdb.com, search for 'The Matrix', and extract the director, release year, and rating",
  {
    outputSchema: z.object({
      director: z.string().describe("The name of the movie director"),
      releaseYear: z.number().describe("The year the movie was released"),
      rating: z.string().describe("The IMDb rating of the movie"),
    }),
  }
);
console.log(agentResponse.output);
await agent.closeAgent();
bash
{
  "director": "Lana Wachowski, Lilly Wachowski",
  "releaseYear": 1999,
  "rating": "8.7/10"
}

Using Different LLM Providers

Hyperagent supports multiple LLM providers with native SDKs for better performance and reliability.

typescript
// Using OpenAI
const agent = new HyperAgent({
  llm: {
    provider: "openai",
    model: "gpt-4o",
  },
});

// Using Anthropic's Claude
const agent = new HyperAgent({
  llm: {
    provider: "anthropic",
    model: "claude-sonnet-4-0",
  },
});

// Using Google Gemini
const agent = new HyperAgent({
  llm: {
    provider: "gemini",
    model: "gemini-2.5-flash",
  },
});

// Using DeepSeek
const agent = new HyperAgent({
  llm: {
    provider: "deepseek",
    model: "deepseek-chat",
  },
});

MCP Support

HyperAgent functions as a fully functional MCP client. For best results, we recommend using gpt-4o as your LLM.

Here is an example which reads from wikipedia, and inserts information into a google sheet using the composio Google Sheet MCP. For the full example, see here

…

Custom Actions

HyperAgent's capabilities can be extended with custom actions. Custom actions require 3 things:

  • type: Name of the action. Should be something descriptive about the action.
  • actionParams: A zod object describing the parameters that the action may consume.
  • run: A function that takes in a context, and the params for the action and produces a result based on the params.

Here is an example that performs a search using Exa

…

Action Caching

HyperAgent automatically records every action during page.ai() runs, capturing XPaths, frame indices, and execution details. This enables deterministic replay without LLM calls—perfect for regression testing, CI pipelines, and cost optimization.

How It Works

Every page.ai() run produces an actionCache containing the exact sequence of actions performed:

typescript
const page = await agent.newPage();
const { actionCache } = await page.ai(
  "Go to flights.google.com and search for flights from Rio to LAX"
);

// actionCache contains the recorded steps
console.log(actionCache);

Example cache entry:

json
{
  "taskId": "86d13abe-b9f3-4ca3-a9bb-bdeddf234cd1",
  "createdAt": "2025-12-06T05:44:52.257Z",
  "status": "completed",
  "steps": [
    {
      "stepIndex": 0,
      "instruction": "Click on the departure field",
      "elementId": "0-138",
      "method": "click",
      "arguments": [],
      "frameIndex": 0,
      "xpath": "/html[1]/body[1]/div[1]/input[1]",
      "actionType": "actElement",
      "success": true
    }
  ]
}

Replaying Cached Actions

Replay a recorded session using runFromActionCache(). It attempts XPath-based execution first (no LLM calls), falling back to LLM only if the page structure has changed:

…

Generating Replay Scripts

Generate a standalone TypeScript script from an action cache for easy integration into your test suite:

typescript
const { actionCache } = await page.ai("search for flights from Miami to NYC");

// Generate a replay script
const script = agent.createScriptFromActionCache(actionCache.steps);
console.log(script);

This produces a script using typed helper methods like performClick(), performType(), etc., that can be run independently.

Use Cases

  • Regression Testing: Record a workflow once, replay it in CI without LLM costs
  • Flaky Test Debugging: Compare XPath-based replay vs LLM-driven execution
  • Cost Optimization: Cache expensive multi-step workflows and replay deterministically
  • Workflow Templates: Save common flows (login, checkout) and replay across environments

CDP First

HyperAgent speaks Chrome DevTools Protocol natively. Element lookup, scrolling, typing, frame management, and screenshots all go through CDP so every action has exact coordinates, execution contexts, and browser events. This allows for more custom commands and deep iframe tracking.

HyperAgent integrates seamlessly with Playwright, so you can still use familiar commands, while the actions take full advantage of native CDP protocol with fast locators and advanced iframe tracking.

Key Features:

  • Auto-Ad Filtering: Automatically filters out ad and tracking iframes to keep context clean
  • Deep Iframe Support: Tracking across nested and cross-origin iframes (OOPIFs)
  • Exact Coordinates: Actions use precise CDP coordinates for reliability

Keep in mind that CDP is still experimental, and stability is not guaranteed. If you'd like the agent to use Playwright's native locators/actions instead, set cdpActions: false when you create the agent and it will fall back automatically.

The CDP layer is still evolving—expect rapid polish (and the occasional sharp edge). If you hit something quirky you can toggle CDP off for that workflow and drop us a bug report.

Contributing

We welcome contributions to Hyperagent! Here's how you can help:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Support

  • Documentation
  • Discord Community
  • Issue Tracker
  • Email Support

Issues· 26 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScriptagentaiautomationchrome

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
CategoryAI 编程
PricingOpen source

> Related tools

G
GitHub Copilot
GitHub 官方 AI 编程助手,覆盖补全、Chat 与 Agent 模式。
C
Cursor
AI 原生代码编辑器,对话改代码、多文件 Agent 与规则体系是其核心。
S
skills
Skills for Real Engineers. Straight from my .agents directory.