@mastra/agent-browser 0.5.2-alpha.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -98
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -33,106 +33,15 @@ then interact with elements using their refs (e.g., @e5).`,
|
|
|
33
33
|
const result = await agent.generate('Go to example.com and click the first link');
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
##
|
|
37
|
-
|
|
38
|
-
```typescript
|
|
39
|
-
const browser = new AgentBrowser({
|
|
40
|
-
// Run headless (default: true)
|
|
41
|
-
headless: true,
|
|
42
|
-
|
|
43
|
-
// Viewport dimensions
|
|
44
|
-
viewport: { width: 1280, height: 720 },
|
|
45
|
-
|
|
46
|
-
// Default timeout for operations in ms (default: 30000)
|
|
47
|
-
timeout: 30000,
|
|
48
|
-
|
|
49
|
-
// CDP URL for connecting to existing browser
|
|
50
|
-
cdpUrl: 'ws://localhost:9222',
|
|
51
|
-
|
|
52
|
-
// Browser instance scope
|
|
53
|
-
// Default: 'thread' for local launch, 'shared' when cdpUrl is provided
|
|
54
|
-
// 'thread': Each thread gets its own browser
|
|
55
|
-
// 'shared': All threads share one browser
|
|
56
|
-
scope: 'thread',
|
|
57
|
-
|
|
58
|
-
// Screencast settings for Studio
|
|
59
|
-
screencast: {
|
|
60
|
-
enabled: true,
|
|
61
|
-
format: 'jpeg',
|
|
62
|
-
quality: 80,
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
## Tools
|
|
68
|
-
|
|
69
|
-
AgentBrowser exposes 15 deterministic tools using accessibility tree refs:
|
|
70
|
-
|
|
71
|
-
### Core Tools
|
|
72
|
-
|
|
73
|
-
- **browser_goto** - Navigate to a URL
|
|
74
|
-
- **browser_snapshot** - Get accessibility tree with element refs (@e1, @e2, etc.)
|
|
75
|
-
- **browser_click** - Click an element by ref
|
|
76
|
-
- **browser_type** - Type text into an element
|
|
77
|
-
- **browser_press** - Press keyboard keys
|
|
78
|
-
- **browser_select** - Select option from dropdown
|
|
79
|
-
- **browser_scroll** - Scroll the page or element
|
|
80
|
-
- **browser_close** - Close the browser
|
|
81
|
-
|
|
82
|
-
### Extended Tools
|
|
83
|
-
|
|
84
|
-
- **browser_hover** - Hover over an element
|
|
85
|
-
- **browser_back** - Go back in browser history
|
|
86
|
-
- **browser_dialog** - Handle browser dialogs (alert, confirm, prompt)
|
|
87
|
-
- **browser_wait** - Wait for element state changes
|
|
88
|
-
- **browser_tabs** - Manage browser tabs (list, new, switch, close)
|
|
89
|
-
- **browser_drag** - Drag and drop elements
|
|
90
|
-
|
|
91
|
-
### Escape Hatch
|
|
92
|
-
|
|
93
|
-
- **browser_evaluate** - Execute JavaScript in the page context
|
|
94
|
-
|
|
95
|
-
## How Refs Work
|
|
96
|
-
|
|
97
|
-
AgentBrowser uses accessibility tree refs for precise element targeting:
|
|
98
|
-
|
|
99
|
-
1. Call `browser_snapshot` to get the page structure with refs
|
|
100
|
-
2. Find the element you want to interact with
|
|
101
|
-
3. Use its ref with other tools
|
|
102
|
-
|
|
103
|
-
```text
|
|
104
|
-
[document] Example Page
|
|
105
|
-
[banner]
|
|
106
|
-
[link @e1] Home
|
|
107
|
-
[link @e2] About
|
|
108
|
-
[main]
|
|
109
|
-
[textbox @e3] Search...
|
|
110
|
-
[button @e4] Submit
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
```typescript
|
|
114
|
-
// Type in the search box
|
|
115
|
-
{ tool: "browser_type", input: { ref: "@e3", text: "mastra" } }
|
|
116
|
-
|
|
117
|
-
// Click submit
|
|
118
|
-
{ tool: "browser_click", input: { ref: "@e4" } }
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
## Comparison with StagehandBrowser
|
|
36
|
+
## Documentation
|
|
122
37
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
| Approach | Deterministic refs (@e1) | Natural language |
|
|
126
|
-
| Token cost | Low | Higher (LLM calls) |
|
|
127
|
-
| Speed | Fast | Slower |
|
|
128
|
-
| Reliability | High (exact refs) | Variable (AI interpretation) |
|
|
129
|
-
| Best for | Structured workflows | Unknown/dynamic pages |
|
|
38
|
+
- [Agent Browser integration guide](https://mastra.ai/integrations/browsers/agent-browser)
|
|
39
|
+
- [Agent Browser reference](https://mastra.ai/reference/browser/agent-browser)
|
|
130
40
|
|
|
131
|
-
##
|
|
41
|
+
## Changelog
|
|
132
42
|
|
|
133
|
-
|
|
134
|
-
- [AgentBrowser reference](https://mastra.ai/reference/browser/agent-browser) - API reference
|
|
43
|
+
See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/browser/agent-browser/CHANGELOG.md) for version history and release notes.
|
|
135
44
|
|
|
136
|
-
##
|
|
45
|
+
## Support
|
|
137
46
|
|
|
138
|
-
|
|
47
|
+
We have an [open community Discord](https://discord.gg/mastra-ai). Come and say hello and let us know if you have any questions or need any help getting things running.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/agent-browser",
|
|
3
|
-
"version": "0.5.2
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Browser automation for Mastra agents using agent-browser",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"typescript": "^7.0.2",
|
|
36
36
|
"vitest": "4.1.10",
|
|
37
37
|
"zod": "^4.4.3",
|
|
38
|
-
"@internal/browser-test-utils": "0.0.
|
|
39
|
-
"@internal/lint": "0.0.
|
|
40
|
-
"@internal/types-builder": "0.0.
|
|
41
|
-
"@mastra/core": "1.64.0
|
|
38
|
+
"@internal/browser-test-utils": "0.0.49",
|
|
39
|
+
"@internal/lint": "0.0.130",
|
|
40
|
+
"@internal/types-builder": "0.0.105",
|
|
41
|
+
"@mastra/core": "1.64.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@mastra/core": ">=1.22.0-0 <2.0.0-0",
|