
Product
Introducing Repository Access Permissions and Custom Roles
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.
@mastra/agent-browser
Advanced tools
Affected versions:
Deterministic browser automation for Mastra agents using agent-browser.
npm install @mastra/agent-browser
import { Agent } from '@mastra/core/agent';
import { AgentBrowser } from '@mastra/agent-browser';
// Create an AgentBrowser instance
const browser = new AgentBrowser({
headless: true,
});
// Create an agent with the browser
const agent = new Agent({
name: 'web-agent',
instructions: `You are a web automation assistant.
Use browser_snapshot to see the page structure,
then interact with elements using their refs (e.g., @e5).`,
model: 'openai/gpt-5.4',
browser,
});
// Use the agent to browse the web
const result = await agent.generate('Go to example.com and click the first link');
const browser = new AgentBrowser({
// Run headless (default: true)
headless: true,
// Viewport dimensions
viewport: { width: 1280, height: 720 },
// Default timeout for operations in ms (default: 30000)
timeout: 30000,
// CDP URL for connecting to existing browser
cdpUrl: 'ws://localhost:9222',
// Browser instance scope
// Default: 'thread' for local launch, 'shared' when cdpUrl is provided
// 'thread': Each thread gets its own browser
// 'shared': All threads share one browser
scope: 'thread',
// Screencast settings for Studio
screencast: {
enabled: true,
format: 'jpeg',
quality: 80,
},
});
AgentBrowser exposes 15 deterministic tools using accessibility tree refs:
AgentBrowser uses accessibility tree refs for precise element targeting:
browser_snapshot to get the page structure with refs[document] Example Page
[banner]
[link @e1] Home
[link @e2] About
[main]
[textbox @e3] Search...
[button @e4] Submit
// Type in the search box
{ tool: "browser_type", input: { ref: "@e3", text: "mastra" } }
// Click submit
{ tool: "browser_click", input: { ref: "@e4" } }
| Feature | AgentBrowser | StagehandBrowser |
|---|---|---|
| Approach | Deterministic refs (@e1) | Natural language |
| Token cost | Low | Higher (LLM calls) |
| Speed | Fast | Slower |
| Reliability | High (exact refs) | Variable (AI interpretation) |
| Best for | Structured workflows | Unknown/dynamic pages |
Apache-2.0
FAQs
Browser automation for Mastra agents using agent-browser
The npm package @mastra/agent-browser receives a total of 8,627 weekly downloads. As such, @mastra/agent-browser popularity was classified as popular.
We found that @mastra/agent-browser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.