@mastra/stagehand 0.0.0-a2a-vnext-20260424123427

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/CHANGELOG.md ADDED
@@ -0,0 +1,132 @@
1
+ # @mastra/stagehand
2
+
3
+ ## 0.0.0-a2a-vnext-20260424123427
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`092271d`](https://github.com/mastra-ai/mastra/commit/092271d86af4cbe0d70cbf32709dd99b58acd3dd)]:
8
+ - @mastra/core@0.0.0-a2a-vnext-20260424123427
9
+
10
+ ## 0.2.1
11
+
12
+ ### Patch Changes
13
+
14
+ - Standardize `headless` default to `true` across all browser providers. Each provider now resolves `headless` once in its constructor and passes it to the thread manager via the base class getter, removing duplicate fallback logic. ([#15696](https://github.com/mastra-ai/mastra/pull/15696))
15
+
16
+ - Updated dependencies [[`733bf53`](https://github.com/mastra-ai/mastra/commit/733bf53d9352aedd3ef38c3d501edb275b65b43c), [`5405b3b`](https://github.com/mastra-ai/mastra/commit/5405b3b35325c5b8fb34fc7ac109bd2feb7bb6fe), [`45e29cb`](https://github.com/mastra-ai/mastra/commit/45e29cb5b5737f3083eb3852db02b944b9cf37ed), [`750b4d3`](https://github.com/mastra-ai/mastra/commit/750b4d3d8231f92e769b2c485921ac5a8ca639b9), [`c321127`](https://github.com/mastra-ai/mastra/commit/c3211275fc195de9ad1ead2746b354beb8eae6e8), [`a07bcef`](https://github.com/mastra-ai/mastra/commit/a07bcefea77c03d6d322caad973dca49b4b15fa1), [`696694e`](https://github.com/mastra-ai/mastra/commit/696694e00f29241a25dd1a1b749afa06c3a626b4), [`b084a80`](https://github.com/mastra-ai/mastra/commit/b084a800db0f82d62e1fc3d6e3e3480da1ba5a53), [`82b7a96`](https://github.com/mastra-ai/mastra/commit/82b7a964169636c1d1e0c694fc892a213b0179d5), [`df97812`](https://github.com/mastra-ai/mastra/commit/df97812bd949dcafeb074b80ecab501724b49c3b), [`8bbe360`](https://github.com/mastra-ai/mastra/commit/8bbe36042af7fc4be0244dffd8913f6795179421), [`f6b8ba8`](https://github.com/mastra-ai/mastra/commit/f6b8ba8dbf533b7a8db90c72b6805ddc804a3a72), [`a07bcef`](https://github.com/mastra-ai/mastra/commit/a07bcefea77c03d6d322caad973dca49b4b15fa1)]:
17
+ - @mastra/core@1.28.0
18
+
19
+ ## 0.2.1-alpha.0
20
+
21
+ ### Patch Changes
22
+
23
+ - Standardize `headless` default to `true` across all browser providers. Each provider now resolves `headless` once in its constructor and passes it to the thread manager via the base class getter, removing duplicate fallback logic. ([#15696](https://github.com/mastra-ai/mastra/pull/15696))
24
+
25
+ - Updated dependencies [[`750b4d3`](https://github.com/mastra-ai/mastra/commit/750b4d3d8231f92e769b2c485921ac5a8ca639b9)]:
26
+ - @mastra/core@1.28.0-alpha.1
27
+
28
+ ## 0.2.0
29
+
30
+ ### Minor Changes
31
+
32
+ - Added automatic cleanup on browser close: patches `exit_type` to prevent restore dialogs, kills orphaned Chrome child processes, and uses CDP events for reliable disconnect detection in both shared and thread scope. ([#15194](https://github.com/mastra-ai/mastra/pull/15194))
33
+
34
+ ### Patch Changes
35
+
36
+ - dependencies updates: ([#15209](https://github.com/mastra-ai/mastra/pull/15209))
37
+ - Updated dependency [`@browserbasehq/stagehand@^3.2.1` ↗︎](https://www.npmjs.com/package/@browserbasehq/stagehand/v/3.2.1) (from `^3.2.0`, in `dependencies`)
38
+ - Updated dependencies [[`87df955`](https://github.com/mastra-ai/mastra/commit/87df955c028660c075873fd5d74af28233ce32eb), [`8fad147`](https://github.com/mastra-ai/mastra/commit/8fad14759804179c8e080ce4d9dec6ef1a808b31), [`582644c`](https://github.com/mastra-ai/mastra/commit/582644c4a87f83b4f245a84d72b9e8590585012e), [`cbdf3e1`](https://github.com/mastra-ai/mastra/commit/cbdf3e12b3d0c30a6e5347be658e2009648c130a), [`8fe46d3`](https://github.com/mastra-ai/mastra/commit/8fe46d354027f3f0f0846e64219772348de106dd), [`18c67db`](https://github.com/mastra-ai/mastra/commit/18c67dbb9c9ebc26f26f65f7d3ff836e5691ef46), [`4ba3bb1`](https://github.com/mastra-ai/mastra/commit/4ba3bb1e465ad2ddaba3bbf2bc47e0faec32985e), [`5d84914`](https://github.com/mastra-ai/mastra/commit/5d84914e0e520c642a40329b210b413fcd139898), [`8dcc77e`](https://github.com/mastra-ai/mastra/commit/8dcc77e78a5340f5848f74b9e9f1b3da3513c1f5), [`aa67fc5`](https://github.com/mastra-ai/mastra/commit/aa67fc59ee8a5eeff1f23eb05970b8d7a536c8ff), [`fd2f314`](https://github.com/mastra-ai/mastra/commit/fd2f31473d3449b6b97e837ef8641264377f41a7), [`fa8140b`](https://github.com/mastra-ai/mastra/commit/fa8140bcd4251d2e3ac85fdc5547dfc4f372b5be), [`190f452`](https://github.com/mastra-ai/mastra/commit/190f45258b0640e2adfc8219fa3258cdc5b8f071), [`e80fead`](https://github.com/mastra-ai/mastra/commit/e80fead1412cc0d1b2f7d6a1ce5017d9e0098ff7), [`0287b64`](https://github.com/mastra-ai/mastra/commit/0287b644a5c3272755cf3112e71338106664103b), [`7e7bf60`](https://github.com/mastra-ai/mastra/commit/7e7bf606886bf374a6f9d4ca9b09dd83d0533372), [`184907d`](https://github.com/mastra-ai/mastra/commit/184907d775d8609c03c26e78ccaf37315f3aa287), [`075e91a`](https://github.com/mastra-ai/mastra/commit/075e91a4549baf46ad7a42a6a8ac8dfa78cc09e6), [`0c4cd13`](https://github.com/mastra-ai/mastra/commit/0c4cd131931c04ac5405373c932a242dbe88edd6), [`b16a753`](https://github.com/mastra-ai/mastra/commit/b16a753d5748440248d7df82e29bb987a9c8386c)]:
39
+ - @mastra/core@1.25.0
40
+
41
+ ## 0.2.0-alpha.0
42
+
43
+ ### Minor Changes
44
+
45
+ - Added automatic cleanup on browser close: patches `exit_type` to prevent restore dialogs, kills orphaned Chrome child processes, and uses CDP events for reliable disconnect detection in both shared and thread scope. ([#15194](https://github.com/mastra-ai/mastra/pull/15194))
46
+
47
+ ### Patch Changes
48
+
49
+ - dependencies updates: ([#15209](https://github.com/mastra-ai/mastra/pull/15209))
50
+ - Updated dependency [`@browserbasehq/stagehand@^3.2.1` ↗︎](https://www.npmjs.com/package/@browserbasehq/stagehand/v/3.2.1) (from `^3.2.0`, in `dependencies`)
51
+ - Updated dependencies [[`cbdf3e1`](https://github.com/mastra-ai/mastra/commit/cbdf3e12b3d0c30a6e5347be658e2009648c130a), [`8fe46d3`](https://github.com/mastra-ai/mastra/commit/8fe46d354027f3f0f0846e64219772348de106dd), [`18c67db`](https://github.com/mastra-ai/mastra/commit/18c67dbb9c9ebc26f26f65f7d3ff836e5691ef46), [`8dcc77e`](https://github.com/mastra-ai/mastra/commit/8dcc77e78a5340f5848f74b9e9f1b3da3513c1f5), [`aa67fc5`](https://github.com/mastra-ai/mastra/commit/aa67fc59ee8a5eeff1f23eb05970b8d7a536c8ff), [`fa8140b`](https://github.com/mastra-ai/mastra/commit/fa8140bcd4251d2e3ac85fdc5547dfc4f372b5be), [`190f452`](https://github.com/mastra-ai/mastra/commit/190f45258b0640e2adfc8219fa3258cdc5b8f071), [`7e7bf60`](https://github.com/mastra-ai/mastra/commit/7e7bf606886bf374a6f9d4ca9b09dd83d0533372), [`184907d`](https://github.com/mastra-ai/mastra/commit/184907d775d8609c03c26e78ccaf37315f3aa287), [`0c4cd13`](https://github.com/mastra-ai/mastra/commit/0c4cd131931c04ac5405373c932a242dbe88edd6), [`b16a753`](https://github.com/mastra-ai/mastra/commit/b16a753d5748440248d7df82e29bb987a9c8386c)]:
52
+ - @mastra/core@1.25.0-alpha.3
53
+
54
+ ## 0.1.0
55
+
56
+ ### Minor Changes
57
+
58
+ - Add AI-powered browser automation with Stagehand SDK integration ([#14938](https://github.com/mastra-ai/mastra/pull/14938))
59
+
60
+ **New Features:**
61
+ - AI-powered browser automation using Stagehand's act/extract/observe primitives
62
+ - Native Browserbase integration for cloud browser sessions
63
+ - Real-time screencast streaming via WebSocket
64
+ - Mouse and keyboard input injection
65
+ - Thread-scoped browser isolation (`scope: 'thread'`)
66
+ - State persistence and restoration across sessions
67
+
68
+ **Configuration:**
69
+
70
+ ```typescript
71
+ import { StagehandBrowser } from '@mastra/stagehand';
72
+
73
+ // Local browser
74
+ const browser = new StagehandBrowser({
75
+ headless: true,
76
+ scope: 'thread',
77
+ });
78
+
79
+ // Browserbase cloud
80
+ const browser = new StagehandBrowser({
81
+ env: 'BROWSERBASE',
82
+ apiKey: process.env.BROWSERBASE_API_KEY,
83
+ projectId: process.env.BROWSERBASE_PROJECT_ID,
84
+ });
85
+
86
+ const agent = mastra.getAgent('my-agent', { browser });
87
+ ```
88
+
89
+ ### Patch Changes
90
+
91
+ - Updated dependencies [[`cb15509`](https://github.com/mastra-ai/mastra/commit/cb15509b58f6a83e11b765c945082afc027db972), [`81e4259`](https://github.com/mastra-ai/mastra/commit/81e425939b4ceeb4f586e9b6d89c3b1c1f2d2fe7), [`951b8a1`](https://github.com/mastra-ai/mastra/commit/951b8a1b5ef7e1474c59dc4f2b9fc1a8b1e508b6), [`80c5668`](https://github.com/mastra-ai/mastra/commit/80c5668e365470d3a96d3e953868fd7a643ff67c), [`3d478c1`](https://github.com/mastra-ai/mastra/commit/3d478c1e13f17b80f330ac49d7aa42ef929b93ff), [`2b4ea10`](https://github.com/mastra-ai/mastra/commit/2b4ea10b053e4ea1ab232d536933a4a3c4cba999), [`a0544f0`](https://github.com/mastra-ai/mastra/commit/a0544f0a1e6bd52ac12676228967c1938e43648d), [`6039f17`](https://github.com/mastra-ai/mastra/commit/6039f176f9c457304825ff1df8c83b8e457376c0), [`06b928d`](https://github.com/mastra-ai/mastra/commit/06b928dfc2f5630d023467476cc5919dfa858d0a), [`6a8d984`](https://github.com/mastra-ai/mastra/commit/6a8d9841f2933456ee1598099f488d742b600054), [`c8c86aa`](https://github.com/mastra-ai/mastra/commit/c8c86aa1458017fbd1c0776fdc0c520d129df8a6)]:
92
+ - @mastra/core@1.22.0
93
+
94
+ ## 0.1.0-alpha.0
95
+
96
+ ### Minor Changes
97
+
98
+ - Add AI-powered browser automation with Stagehand SDK integration ([#14938](https://github.com/mastra-ai/mastra/pull/14938))
99
+
100
+ **New Features:**
101
+ - AI-powered browser automation using Stagehand's act/extract/observe primitives
102
+ - Native Browserbase integration for cloud browser sessions
103
+ - Real-time screencast streaming via WebSocket
104
+ - Mouse and keyboard input injection
105
+ - Thread-scoped browser isolation (`scope: 'thread'`)
106
+ - State persistence and restoration across sessions
107
+
108
+ **Configuration:**
109
+
110
+ ```typescript
111
+ import { StagehandBrowser } from '@mastra/stagehand';
112
+
113
+ // Local browser
114
+ const browser = new StagehandBrowser({
115
+ headless: true,
116
+ scope: 'thread',
117
+ });
118
+
119
+ // Browserbase cloud
120
+ const browser = new StagehandBrowser({
121
+ env: 'BROWSERBASE',
122
+ apiKey: process.env.BROWSERBASE_API_KEY,
123
+ projectId: process.env.BROWSERBASE_PROJECT_ID,
124
+ });
125
+
126
+ const agent = mastra.getAgent('my-agent', { browser });
127
+ ```
128
+
129
+ ### Patch Changes
130
+
131
+ - Updated dependencies [[`cb15509`](https://github.com/mastra-ai/mastra/commit/cb15509b58f6a83e11b765c945082afc027db972), [`80c5668`](https://github.com/mastra-ai/mastra/commit/80c5668e365470d3a96d3e953868fd7a643ff67c), [`3d478c1`](https://github.com/mastra-ai/mastra/commit/3d478c1e13f17b80f330ac49d7aa42ef929b93ff), [`6039f17`](https://github.com/mastra-ai/mastra/commit/6039f176f9c457304825ff1df8c83b8e457376c0), [`06b928d`](https://github.com/mastra-ai/mastra/commit/06b928dfc2f5630d023467476cc5919dfa858d0a), [`6a8d984`](https://github.com/mastra-ai/mastra/commit/6a8d9841f2933456ee1598099f488d742b600054)]:
132
+ - @mastra/core@1.22.0-alpha.2
package/LICENSE.md ADDED
@@ -0,0 +1,30 @@
1
+ Portions of this software are licensed as follows:
2
+
3
+ - All content that resides under any directory named "ee/" within this
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`.
8
+
9
+ - All third-party components incorporated into the Mastra Software are
10
+ licensed under the original license provided by the owner of the
11
+ applicable component.
12
+
13
+ - Content outside of the above-mentioned directories or restrictions is
14
+ available under the "Apache License 2.0" as defined below.
15
+
16
+ # Apache License 2.0
17
+
18
+ Copyright (c) 2025 Kepler Software, Inc.
19
+
20
+ Licensed under the Apache License, Version 2.0 (the "License");
21
+ you may not use this file except in compliance with the License.
22
+ You may obtain a copy of the License at
23
+
24
+ http://www.apache.org/licenses/LICENSE-2.0
25
+
26
+ Unless required by applicable law or agreed to in writing, software
27
+ distributed under the License is distributed on an "AS IS" BASIS,
28
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29
+ See the License for the specific language governing permissions and
30
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,110 @@
1
+ # @mastra/stagehand
2
+
3
+ AI-powered browser automation for Mastra agents using [Stagehand](https://github.com/browserbase/stagehand).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @mastra/stagehand
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { Agent } from '@mastra/core/agent';
15
+ import { StagehandBrowser } from '@mastra/stagehand';
16
+
17
+ // Create a Stagehand browser
18
+ const browser = new StagehandBrowser({
19
+ model: 'openai/gpt-5.4',
20
+ headless: true,
21
+ });
22
+
23
+ // Create an agent with the browser
24
+ const agent = new Agent({
25
+ name: 'web-agent',
26
+ instructions: 'You are a helpful web assistant.',
27
+ model: 'openai/gpt-5.4',
28
+ browser,
29
+ });
30
+
31
+ // Use the agent to browse the web with natural language
32
+ const result = await agent.generate('Go to google.com and search for "Mastra AI"');
33
+ ```
34
+
35
+ ## Configuration
36
+
37
+ ```typescript
38
+ const browser = new StagehandBrowser({
39
+ // Environment: 'LOCAL' or 'BROWSERBASE'
40
+ env: 'LOCAL',
41
+
42
+ // Model for AI operations (default: 'openai/gpt-5.4')
43
+ model: 'openai/gpt-5.4',
44
+ // Or with custom config:
45
+ model: {
46
+ modelName: 'gpt-5.4',
47
+ apiKey: process.env.OPENAI_API_KEY,
48
+ },
49
+
50
+ // Run headless (default: true)
51
+ headless: true,
52
+
53
+ // Viewport dimensions
54
+ viewport: { width: 1280, height: 720 },
55
+
56
+ // CDP URL for connecting to existing browser
57
+ cdpUrl: 'ws://localhost:9222',
58
+
59
+ // Browserbase config (when env: 'BROWSERBASE')
60
+ apiKey: process.env.BROWSERBASE_API_KEY,
61
+ projectId: process.env.BROWSERBASE_PROJECT_ID,
62
+
63
+ // Enable self-healing selectors (default: true)
64
+ selfHeal: true,
65
+
66
+ // DOM settle timeout in ms (default: 5000)
67
+ domSettleTimeout: 5000,
68
+
69
+ // Logging verbosity (0: silent, 1: errors, 2: verbose)
70
+ verbose: 1,
71
+
72
+ // Custom system prompt for AI operations
73
+ systemPrompt: 'Focus on finding interactive elements',
74
+ });
75
+ ```
76
+
77
+ ## Tools
78
+
79
+ StagehandBrowser exposes 6 AI-powered tools:
80
+
81
+ ### Core AI Tools
82
+
83
+ - **stagehand_act** - Perform actions using natural language instructions
84
+ - **stagehand_extract** - Extract structured data from pages
85
+ - **stagehand_observe** - Discover actionable elements on the page
86
+
87
+ ### Navigation & State
88
+
89
+ - **stagehand_navigate** - Navigate to a URL
90
+ - **stagehand_tabs** - List, switch, open, or close browser tabs
91
+ - **stagehand_close** - Close the browser
92
+
93
+ ## Comparison with AgentBrowser
94
+
95
+ | Feature | AgentBrowser | StagehandBrowser |
96
+ | ----------- | ------------------------ | ---------------------------- |
97
+ | Approach | Deterministic refs (@e1) | Natural language |
98
+ | Token cost | Low | Higher (LLM calls) |
99
+ | Speed | Fast | Slower |
100
+ | Reliability | High (exact refs) | Variable (AI interpretation) |
101
+ | Best for | Structured workflows | Unknown/dynamic pages |
102
+
103
+ ## Documentation
104
+
105
+ - [Stagehand guide](https://mastra.ai/docs/browser/stagehand) - Usage guide
106
+ - [StagehandBrowser reference](https://mastra.ai/reference/browser/stagehand-browser) - API reference
107
+
108
+ ## License
109
+
110
+ Apache-2.0