@mastra/agent-browser 0.5.1 → 0.5.2-alpha.1

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/LICENSE.md CHANGED
@@ -1,10 +1,12 @@
1
1
  Portions of this software are licensed as follows:
2
2
 
3
- - All content that resides under any directory named "ee/" within this
3
+ - All content that resides under any directory named `ee/` within this
4
4
  repository, including but not limited to:
5
- - `packages/core/src/auth/ee/`
6
- - `packages/server/src/server/auth/ee/`
7
- is licensed under the license defined in `ee/LICENSE`.
5
+ - `@mastra/core/auth/ee`
6
+ - `@mastra/core/agent-builder/ee`
7
+ - `@mastra/editor/ee`
8
+
9
+ is licensed under the license defined in [`ee/LICENSE`](https://github.com/mastra-ai/mastra/blob/main/ee/LICENSE).
8
10
 
9
11
  - All third-party components incorporated into the Mastra Software are
10
12
  licensed under the original license provided by the owner of the
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
- ## Configuration
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
- | Feature | AgentBrowser | StagehandBrowser |
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
- ## Documentation
41
+ ## Changelog
132
42
 
133
- - [agent-browser guide](https://mastra.ai/docs/browser/agent-browser) - Usage guide
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
- ## License
45
+ ## Support
137
46
 
138
- Apache-2.0
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/dist/index.d.cts CHANGED
@@ -44170,8 +44170,8 @@ interface PageScreenshotOptions {
44170
44170
  declare const gotoInputSchema: z.ZodObject<{
44171
44171
  url: z.ZodString;
44172
44172
  waitUntil: z.ZodOptional<z.ZodEnum<{
44173
- load: "load";
44174
44173
  domcontentloaded: "domcontentloaded";
44174
+ load: "load";
44175
44175
  networkidle: "networkidle";
44176
44176
  }>>;
44177
44177
  timeout: z.ZodOptional<z.ZodNumber>;
@@ -44192,8 +44192,8 @@ declare const clickInputSchema: z.ZodObject<{
44192
44192
  ref: z.ZodString;
44193
44193
  button: z.ZodOptional<z.ZodEnum<{
44194
44194
  left: "left";
44195
- right: "right";
44196
44195
  middle: "middle";
44196
+ right: "right";
44197
44197
  }>>;
44198
44198
  clickCount: z.ZodOptional<z.ZodNumber>;
44199
44199
  modifiers: z.ZodOptional<z.ZodArray<z.ZodEnum<{
@@ -44203,8 +44203,8 @@ declare const clickInputSchema: z.ZodObject<{
44203
44203
  Shift: "Shift";
44204
44204
  }>>>;
44205
44205
  waitUntil: z.ZodOptional<z.ZodEnum<{
44206
- load: "load";
44207
44206
  domcontentloaded: "domcontentloaded";
44207
+ load: "load";
44208
44208
  networkidle: "networkidle";
44209
44209
  }>>;
44210
44210
  timeout: z.ZodOptional<z.ZodNumber>;
@@ -44232,8 +44232,8 @@ declare const pressInputSchema: z.ZodObject<{
44232
44232
  Shift: "Shift";
44233
44233
  }>>>;
44234
44234
  waitUntil: z.ZodOptional<z.ZodEnum<{
44235
- load: "load";
44236
44235
  domcontentloaded: "domcontentloaded";
44236
+ load: "load";
44237
44237
  networkidle: "networkidle";
44238
44238
  }>>;
44239
44239
  timeout: z.ZodOptional<z.ZodNumber>;
@@ -44248,8 +44248,8 @@ declare const selectInputSchema: z.ZodObject<{
44248
44248
  label: z.ZodOptional<z.ZodString>;
44249
44249
  index: z.ZodOptional<z.ZodNumber>;
44250
44250
  waitUntil: z.ZodOptional<z.ZodEnum<{
44251
- load: "load";
44252
44251
  domcontentloaded: "domcontentloaded";
44252
+ load: "load";
44253
44253
  networkidle: "networkidle";
44254
44254
  }>>;
44255
44255
  timeout: z.ZodOptional<z.ZodNumber>;
@@ -44260,10 +44260,10 @@ type SelectInput = z.output<typeof selectInputSchema>;
44260
44260
  */
44261
44261
  declare const scrollInputSchema: z.ZodObject<{
44262
44262
  direction: z.ZodEnum<{
44263
+ down: "down";
44263
44264
  left: "left";
44264
44265
  right: "right";
44265
44266
  up: "up";
44266
- down: "down";
44267
44267
  }>;
44268
44268
  amount: z.ZodOptional<z.ZodNumber>;
44269
44269
  ref: z.ZodOptional<z.ZodString>;
@@ -44304,10 +44304,10 @@ type DialogInput = z.output<typeof dialogInputSchema>;
44304
44304
  declare const waitInputSchema: z.ZodObject<{
44305
44305
  ref: z.ZodOptional<z.ZodString>;
44306
44306
  state: z.ZodOptional<z.ZodEnum<{
44307
- visible: "visible";
44308
- hidden: "hidden";
44309
44307
  attached: "attached";
44310
44308
  detached: "detached";
44309
+ hidden: "hidden";
44310
+ visible: "visible";
44311
44311
  }>>;
44312
44312
  timeout: z.ZodOptional<z.ZodNumber>;
44313
44313
  }, z.core.$strip>;
@@ -44317,10 +44317,10 @@ type WaitInput = z.output<typeof waitInputSchema>;
44317
44317
  */
44318
44318
  declare const tabsInputSchema: z.ZodObject<{
44319
44319
  action: z.ZodEnum<{
44320
+ close: "close";
44320
44321
  list: "list";
44321
44322
  new: "new";
44322
44323
  switch: "switch";
44323
- close: "close";
44324
44324
  }>;
44325
44325
  index: z.ZodOptional<z.ZodNumber>;
44326
44326
  url: z.ZodOptional<z.ZodString>;
@@ -44355,8 +44355,8 @@ declare const browserSchemas: {
44355
44355
  readonly goto: z.ZodObject<{
44356
44356
  url: z.ZodString;
44357
44357
  waitUntil: z.ZodOptional<z.ZodEnum<{
44358
- load: "load";
44359
44358
  domcontentloaded: "domcontentloaded";
44359
+ load: "load";
44360
44360
  networkidle: "networkidle";
44361
44361
  }>>;
44362
44362
  timeout: z.ZodOptional<z.ZodNumber>;
@@ -44369,8 +44369,8 @@ declare const browserSchemas: {
44369
44369
  ref: z.ZodString;
44370
44370
  button: z.ZodOptional<z.ZodEnum<{
44371
44371
  left: "left";
44372
- right: "right";
44373
44372
  middle: "middle";
44373
+ right: "right";
44374
44374
  }>>;
44375
44375
  clickCount: z.ZodOptional<z.ZodNumber>;
44376
44376
  modifiers: z.ZodOptional<z.ZodArray<z.ZodEnum<{
@@ -44380,8 +44380,8 @@ declare const browserSchemas: {
44380
44380
  Shift: "Shift";
44381
44381
  }>>>;
44382
44382
  waitUntil: z.ZodOptional<z.ZodEnum<{
44383
- load: "load";
44384
44383
  domcontentloaded: "domcontentloaded";
44384
+ load: "load";
44385
44385
  networkidle: "networkidle";
44386
44386
  }>>;
44387
44387
  timeout: z.ZodOptional<z.ZodNumber>;
@@ -44401,8 +44401,8 @@ declare const browserSchemas: {
44401
44401
  Shift: "Shift";
44402
44402
  }>>>;
44403
44403
  waitUntil: z.ZodOptional<z.ZodEnum<{
44404
- load: "load";
44405
44404
  domcontentloaded: "domcontentloaded";
44405
+ load: "load";
44406
44406
  networkidle: "networkidle";
44407
44407
  }>>;
44408
44408
  timeout: z.ZodOptional<z.ZodNumber>;
@@ -44413,18 +44413,18 @@ declare const browserSchemas: {
44413
44413
  label: z.ZodOptional<z.ZodString>;
44414
44414
  index: z.ZodOptional<z.ZodNumber>;
44415
44415
  waitUntil: z.ZodOptional<z.ZodEnum<{
44416
- load: "load";
44417
44416
  domcontentloaded: "domcontentloaded";
44417
+ load: "load";
44418
44418
  networkidle: "networkidle";
44419
44419
  }>>;
44420
44420
  timeout: z.ZodOptional<z.ZodNumber>;
44421
44421
  }, z.core.$strip>;
44422
44422
  readonly scroll: z.ZodObject<{
44423
44423
  direction: z.ZodEnum<{
44424
+ down: "down";
44424
44425
  left: "left";
44425
44426
  right: "right";
44426
44427
  up: "up";
44427
- down: "down";
44428
44428
  }>;
44429
44429
  amount: z.ZodOptional<z.ZodNumber>;
44430
44430
  ref: z.ZodOptional<z.ZodString>;
@@ -44445,19 +44445,19 @@ declare const browserSchemas: {
44445
44445
  readonly wait: z.ZodObject<{
44446
44446
  ref: z.ZodOptional<z.ZodString>;
44447
44447
  state: z.ZodOptional<z.ZodEnum<{
44448
- visible: "visible";
44449
- hidden: "hidden";
44450
44448
  attached: "attached";
44451
44449
  detached: "detached";
44450
+ hidden: "hidden";
44451
+ visible: "visible";
44452
44452
  }>>;
44453
44453
  timeout: z.ZodOptional<z.ZodNumber>;
44454
44454
  }, z.core.$strip>;
44455
44455
  readonly tabs: z.ZodObject<{
44456
44456
  action: z.ZodEnum<{
44457
+ close: "close";
44457
44458
  list: "list";
44458
44459
  new: "new";
44459
44460
  switch: "switch";
44460
- close: "close";
44461
44461
  }>;
44462
44462
  index: z.ZodOptional<z.ZodNumber>;
44463
44463
  url: z.ZodOptional<z.ZodString>;
@@ -44482,22 +44482,22 @@ declare const browserSchemas: {
44482
44482
  * Browser Tool Constants
44483
44483
  */
44484
44484
  declare const BROWSER_TOOLS: {
44485
- readonly GOTO: "browser_goto";
44486
- readonly SNAPSHOT: "browser_snapshot";
44487
- readonly CLICK: "browser_click";
44488
- readonly TYPE: "browser_type";
44489
- readonly PRESS: "browser_press";
44490
- readonly SELECT: "browser_select";
44491
- readonly SCROLL: "browser_scroll";
44492
- readonly CLOSE: "browser_close";
44493
- readonly HOVER: "browser_hover";
44494
- readonly BACK: "browser_back";
44495
- readonly DIALOG: "browser_dialog";
44496
- readonly WAIT: "browser_wait";
44497
- readonly TABS: "browser_tabs";
44498
- readonly DRAG: "browser_drag";
44499
- readonly SCREENSHOT: "browser_screenshot";
44500
- readonly EVALUATE: "browser_evaluate";
44485
+ readonly GOTO: 'browser_goto';
44486
+ readonly SNAPSHOT: 'browser_snapshot';
44487
+ readonly CLICK: 'browser_click';
44488
+ readonly TYPE: 'browser_type';
44489
+ readonly PRESS: 'browser_press';
44490
+ readonly SELECT: 'browser_select';
44491
+ readonly SCROLL: 'browser_scroll';
44492
+ readonly CLOSE: 'browser_close';
44493
+ readonly HOVER: 'browser_hover';
44494
+ readonly BACK: 'browser_back';
44495
+ readonly DIALOG: 'browser_dialog';
44496
+ readonly WAIT: 'browser_wait';
44497
+ readonly TABS: 'browser_tabs';
44498
+ readonly DRAG: 'browser_drag';
44499
+ readonly SCREENSHOT: 'browser_screenshot';
44500
+ readonly EVALUATE: 'browser_evaluate';
44501
44501
  };
44502
44502
  type BrowserToolName = (typeof BROWSER_TOOLS)[keyof typeof BROWSER_TOOLS];
44503
44503
  //#endregion