Skip to content

lightfeed/browser-agent

Repository files navigation

Serverless Browser Agent ⚡️

Use AI to navigate and interact with web browsers in serverless platforms

Installation

npm install @lightfeed/browser-agent

Quick Start

Serverless

Perfect for AWS Lambda and other serverless environments. Uses @sparticuz/chromium to run Chrome in serverless environments with minimal cold start times and memory usage.

Important

This project uses Playwright, which ships with a specific version of Chromium. You need to install the matching version of @sparticuz/chromium. For example, we are using Playwright 1.48 (which supports Chromium 130), you should install @sparticuz/chromium@130.

import { BrowserAgent } from "@lightfeed/browser-agent";
import chromium from "@sparticuz/chromium";
import { AxiosProxyConfig } from "axios";

const agent = new BrowserAgent({
  browserProvider: "Serverless",
  serverlessConfig: {
    executablePath: await chromium.executablePath(),
    options: {
      args: chromium.args,
    },
    // Use proxy (optional)
    proxy: {
      host: "proxy.example.com",
      port: 8080,
      auth: {
        username: "user",
        password: "pass"
      }
    } as AxiosProxyConfig
  }
});

// Example Lambda handler
export const handler = async (event) => {
  const page = await agent.newPage();
  await page.goto("https://ycombinator.com/companies");

  page.ai("Find real estate YC startups in the latest two batches");
  // ...
};

Remote Browser

Connect to any remote browser instance via WebSocket. Great for:

  • Brightdata's Scraping Browser
  • Custom browser instances in the cloud
  • Browser farms and proxy services
import { BrowserAgent } from "@lightfeed/browser-agent";

const agent = new BrowserAgent({
  browserProvider: "Remote",
  remoteConfig: {
    browserWSEndpoint: "ws://your-remote-browser:9222/devtools/browser/ws"
  }
});

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

page.ai("Search for organic products and go to the second page");

Local Browser

Use your local Chrome browser for development and testing. Perfect for:

  • Local development and debugging
  • Testing automation scripts
  • Quick prototyping
import { BrowserAgent } from "@lightfeed/browser-agent";

const agent = new BrowserAgent({
  browserProvider: "Local"
});

const page = await agent.newPage();
await page.goto("https://news.ycombinator.com");

page.ai("Navigate to show section and go to the second post");

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

About

Serverless AI browser agent

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 5