Use AI to navigate and interact with web browsers in serverless platforms
npm install @lightfeed/browser-agent
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. Supports proxy configuration for geo-tracking and unblocking.
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 to Chromium 130), you should install @sparticuz/chromium@130
.
For running on AWS Lambda, lambda layer with ARM64 architecture is preferred. You will also need to install dependencies of canvas. Here is an example of Lambda Layer Build Script.
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");
// ...
};
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");
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");
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- Forked from HyperAgent version b49afe under MIT License
- Browser support in serverless environments by @sparticuz/chromium