This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @browserbasehq/stagehand@3.1.0 ### Minor Changes - [#1681](https://github.com/browserbase/stagehand/pull/1681) [`e3db9aa`](e3db9aa863) Thanks [@tkattkat](https://github.com/tkattkat)! - Add cookie management APIs: `context.addCookies()`, `context.clearCookies()`, & `context.cookies()` - [#1672](https://github.com/browserbase/stagehand/pull/1672) [`b65756e`](b65756e9e8) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - add boolean keepAlive parameter to allow for configuring whether the browser should be closed when stagehand.close() is called. - [#1708](https://github.com/browserbase/stagehand/pull/1708) [`176d420`](176d42002c) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - add context.setExtraHTTPHeaders() - [#1611](https://github.com/browserbase/stagehand/pull/1611) [`8a3c066`](8a3c06600a) Thanks [@monadoid](https://github.com/monadoid)! - Using `mode` enum instead of old `cua` boolean in openapi spec ### Patch Changes - [#1683](https://github.com/browserbase/stagehand/pull/1683) [`7584f3e`](7584f3e92e) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - fix: include shadow DOM in .count() & .nth() & support xpath predicates - [#1644](https://github.com/browserbase/stagehand/pull/1644) [`1e1c9c1`](1e1c9c1577) Thanks [@monadoid](https://github.com/monadoid)! - Fix unhandled CDP detaches by returning the original sendCDP promise - [#1729](https://github.com/browserbase/stagehand/pull/1729) [`6bef890`](6bef89090e) Thanks [@shrey150](https://github.com/shrey150)! - fix: support Claude 4.6 (Opus and Sonnet) in CUA mode by using the correct `computer_20251124` tool version and `computer-use-2025-11-24` beta header - [#1647](https://github.com/browserbase/stagehand/pull/1647) [`ffd4b33`](ffd4b335a8) Thanks [@tkattkat](https://github.com/tkattkat)! - Fix [Agent] - Address bug causing issues with continuing a conversation from past messages in dom mode - [#1614](https://github.com/browserbase/stagehand/pull/1614) [`677bff5`](677bff5834) Thanks [@miguelg719](https://github.com/miguelg719)! - Enforce <number>-<number> regex validation on act/observe for elementId - [#1580](https://github.com/browserbase/stagehand/pull/1580) [`65ff464`](65ff464bc1) Thanks [@tkattkat](https://github.com/tkattkat)! - Add unified variables support across act and agent with a single VariableValue type - [#1666](https://github.com/browserbase/stagehand/pull/1666) [`101bcf2`](101bcf2da8) Thanks [@Kylejeong2](https://github.com/Kylejeong2)! - add support for codex models - [#1728](https://github.com/browserbase/stagehand/pull/1728) [`0a94301`](0a94301caa) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - handle potential race condition on `.close()` when using the Stagehand API - [#1664](https://github.com/browserbase/stagehand/pull/1664) [`b27c04d`](b27c04d278) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - fixes issue with context.addInitScript() where scripts were not being applied to out of process iframes (OOPIFs), and popup pages with same process iframes (SPIFs) - [#1632](https://github.com/browserbase/stagehand/pull/1632) [`afbd08b`](afbd08bb63) Thanks [@pirate](https://github.com/pirate)! - Remove automatic `.env` loading via `dotenv`. If your app relies on `.env` files, install `dotenv` and load it explicitly in your code: ```ts import dotenv from "dotenv"; dotenv.config({ path: ".env" }); ``` - [#1624](https://github.com/browserbase/stagehand/pull/1624) [`0e8d569`](0e8d5695f6) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - fix issue where screenshot masks were not being applied to dialog elements - [#1596](https://github.com/browserbase/stagehand/pull/1596) [`ff0f979`](ff0f9795f3) Thanks [@tkattkat](https://github.com/tkattkat)! - Update usage/metrics handling in agent - [#1631](https://github.com/browserbase/stagehand/pull/1631) [`2d89d2b`](2d89d2b35c) Thanks [@miguelg719](https://github.com/miguelg719)! - Add right and middle click support to act and observe - [#1697](https://github.com/browserbase/stagehand/pull/1697) [`aac9a19`](aac9a19bdf) Thanks [@shrey150](https://github.com/shrey150)! - fix: support `<frame>` elements in XPath frame boundary detection so `act()` works on legacy `<frameset>` pages - [#1692](https://github.com/browserbase/stagehand/pull/1692) [`06de50f`](06de50ff37) Thanks [@shrey150](https://github.com/shrey150)! - fix: skip piercer injection for chrome-extension:// and other non-HTML targets - [#1613](https://github.com/browserbase/stagehand/pull/1613) [`aa4d981`](aa4d981e44) Thanks [@miguelg719](https://github.com/miguelg719)! - SupportedUnderstudyAction Enum validation for 'method' on act/observe inference - [#1652](https://github.com/browserbase/stagehand/pull/1652) [`18b1e3b`](18b1e3bd2b) Thanks [@miguelg719](https://github.com/miguelg719)! - Add support for gemini 3 flash and pro in hybrid/cua agent - [#1706](https://github.com/browserbase/stagehand/pull/1706) [`957d82b`](957d82b984) Thanks [@chrisreadsf](https://github.com/chrisreadsf)! - Add GLM to prompt-based JSON fallback for models without native structured output support - [#1633](https://github.com/browserbase/stagehand/pull/1633) [`22e371a`](22e371ae4c) Thanks [@tkattkat](https://github.com/tkattkat)! - Add warning when incorrect models are used with agents hybrid mode - [#1673](https://github.com/browserbase/stagehand/pull/1673) [`d29b91f`](d29b91fa50) Thanks [@miguelg719](https://github.com/miguelg719)! - Add multi-region support for Stagehand API with region-specific endpoints - [#1695](https://github.com/browserbase/stagehand/pull/1695) [`7b4f817`](7b4f817caf) Thanks [@tkattkat](https://github.com/tkattkat)! - Fix: zod bug when pinning zod to v3 and using structured output in agent - [#1609](https://github.com/browserbase/stagehand/pull/1609) [`3f9ca4d`](3f9ca4d9ac) Thanks [@miguelg719](https://github.com/miguelg719)! - Add SupportedUnderstudyActions to observe system prompt - [#1581](https://github.com/browserbase/stagehand/pull/1581) [`49ead1e`](49ead1e1e8) Thanks [@sameelarif](https://github.com/sameelarif)! - **Server-side caching is now available.** When running `env: "BROWSERBASE"`, Stagehand automatically caches `act()`, `extract()`, and `observe()` results server-side — repeated calls with the same inputs return instantly without consuming LLM tokens. Caching is enabled by default and can be disabled via `serverCache: false` on the Stagehand instance or per individual call. Check out the [browserbase blog](https://www.browserbase.com/blog/stagehand-caching) for more details. - [#1642](https://github.com/browserbase/stagehand/pull/1642) [`3673369`](36733691f9) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - fix issue where scripts added via context.addInitScripts() were not being injected into new pages that were opened via popups (eg, clicking a link that opens a new page) and/or calling context.newPage(url) - [#1735](https://github.com/browserbase/stagehand/pull/1735) [`c465e87`](c465e87ab4) Thanks [@monadoid](https://github.com/monadoid)! - Supports request header authentication with connectToMCPServer - [#1705](https://github.com/browserbase/stagehand/pull/1705) [`ae533e4`](ae533e4019) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - include error cause in UnderstudyCommandException - [#1636](https://github.com/browserbase/stagehand/pull/1636) [`ea33052`](ea330520a3) Thanks [@miguelg719](https://github.com/miguelg719)! - Include executionModel on the AgentConfigSchema - [#1679](https://github.com/browserbase/stagehand/pull/1679) [`5764ede`](5764edee7a) Thanks [@shrey150](https://github.com/shrey150)! - fix issue where locator.count() was not working with xpaths that have attribute predicates - [#1646](https://github.com/browserbase/stagehand/pull/1646) [`f09b184`](f09b184cc5) Thanks [@miguelg719](https://github.com/miguelg719)! - Add user-agent to CDP connections - [#1637](https://github.com/browserbase/stagehand/pull/1637) [`a7d29de`](a7d29decee) Thanks [@miguelg719](https://github.com/miguelg719)! - Improve error and warning message for legacy model format - [#1685](https://github.com/browserbase/stagehand/pull/1685) [`d334399`](d334399004) Thanks [@tkattkat](https://github.com/tkattkat)! - Bump ai sdk & google provider version - [#1662](https://github.com/browserbase/stagehand/pull/1662) [`44416da`](44416da7ff) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - fix issue where locator.fill() was not working on elements that require direct value setting - [#1612](https://github.com/browserbase/stagehand/pull/1612) [`bdd8b4e`](bdd8b4ee3c) Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - fix issue where screenshot mask was only being applied to the first element that the locator resolved to. masks now apply to all matching elements. ## @browserbasehq/stagehand-server@3.6.0 ### Minor Changes - [#1611](https://github.com/browserbase/stagehand/pull/1611) [`8a3c066`](8a3c06600a) Thanks [@monadoid](https://github.com/monadoid)! - Using `mode` enum instead of old `cua` boolean in openapi spec ### Patch Changes - [#1604](https://github.com/browserbase/stagehand/pull/1604) [`4753078`](4753078cc9) Thanks [@miguelg719](https://github.com/miguelg719)! - Enable bedrock - [#1636](https://github.com/browserbase/stagehand/pull/1636) [`ea33052`](ea330520a3) Thanks [@miguelg719](https://github.com/miguelg719)! - Include executionModel on the AgentConfigSchema - [#1602](https://github.com/browserbase/stagehand/pull/1602) [`22a0502`](22a0502e8b) Thanks [@miguelg719](https://github.com/miguelg719)! - Include vertex as a supported provider - Updated dependencies \[[`7584f3e`](7584f3e92e), [`1e1c9c1`](1e1c9c1577), [`6bef890`](6bef89090e), [`ffd4b33`](ffd4b335a8), [`677bff5`](677bff5834), [`65ff464`](65ff464bc1), [`101bcf2`](101bcf2da8), [`0a94301`](0a94301caa), [`b27c04d`](b27c04d278), [`afbd08b`](afbd08bb63), [`e3db9aa`](e3db9aa863), [`0e8d569`](0e8d5695f6), [`ff0f979`](ff0f9795f3), [`2d89d2b`](2d89d2b35c), [`aac9a19`](aac9a19bdf), [`06de50f`](06de50ff37), [`aa4d981`](aa4d981e44), [`18b1e3b`](18b1e3bd2b), [`957d82b`](957d82b984), [`b65756e`](b65756e9e8), [`22e371a`](22e371ae4c), [`d29b91f`](d29b91fa50), [`7b4f817`](7b4f817caf), [`176d420`](176d42002c), [`3f9ca4d`](3f9ca4d9ac), [`8a3c066`](8a3c06600a), [`49ead1e`](49ead1e1e8), [`3673369`](36733691f9), [`c465e87`](c465e87ab4), [`ae533e4`](ae533e4019), [`ea33052`](ea330520a3), [`5764ede`](5764edee7a), [`f09b184`](f09b184cc5), [`a7d29de`](a7d29decee), [`d334399`](d334399004), [`44416da`](44416da7ff), [`bdd8b4e`](bdd8b4ee3c)]: - @browserbasehq/stagehand@3.1.0 ## @browserbasehq/stagehand-evals@1.1.8 ### Patch Changes - Updated dependencies \[[`7584f3e`](7584f3e92e), [`1e1c9c1`](1e1c9c1577), [`6bef890`](6bef89090e), [`ffd4b33`](ffd4b335a8), [`677bff5`](677bff5834), [`65ff464`](65ff464bc1), [`101bcf2`](101bcf2da8), [`0a94301`](0a94301caa), [`b27c04d`](b27c04d278), [`afbd08b`](afbd08bb63), [`e3db9aa`](e3db9aa863), [`0e8d569`](0e8d5695f6), [`ff0f979`](ff0f9795f3), [`2d89d2b`](2d89d2b35c), [`aac9a19`](aac9a19bdf), [`06de50f`](06de50ff37), [`aa4d981`](aa4d981e44), [`18b1e3b`](18b1e3bd2b), [`957d82b`](957d82b984), [`b65756e`](b65756e9e8), [`22e371a`](22e371ae4c), [`d29b91f`](d29b91fa50), [`7b4f817`](7b4f817caf), [`176d420`](176d42002c), [`3f9ca4d`](3f9ca4d9ac), [`8a3c066`](8a3c06600a), [`49ead1e`](49ead1e1e8), [`3673369`](36733691f9), [`c465e87`](c465e87ab4), [`ae533e4`](ae533e4019), [`ea33052`](ea330520a3), [`5764ede`](5764edee7a), [`f09b184`](f09b184cc5), [`a7d29de`](a7d29decee), [`d334399`](d334399004), [`44416da`](44416da7ff), [`bdd8b4e`](bdd8b4ee3c)]: - @browserbasehq/stagehand@3.1.0 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
The AI Browser Automation Framework
Read the Docs
If you're looking for the Python implementation, you can find it here
What is Stagehand?
Stagehand is a browser automation framework used to control web browsers with natural language and code. By combining the power of AI with the precision of code, Stagehand makes web automation flexible, maintainable, and actually reliable.
Why Stagehand?
Most existing browser automation tools either require you to write low-level code in a framework like Selenium, Playwright, or Puppeteer, or use high-level agents that can be unpredictable in production. By letting developers choose what to write in code vs. natural language (and bridging the gap between the two) Stagehand is the natural choice for browser automations in production.
-
Choose when to write code vs. natural language: use AI when you want to navigate unfamiliar pages, and use code when you know exactly what you want to do.
-
Go from AI-driven to repeatable workflows: Stagehand lets you preview AI actions before running them, and also helps you easily cache repeatable actions to save time and tokens.
-
Write once, run forever: Stagehand's auto-caching combined with self-healing remembers previous actions, runs without LLM inference, and knows when to involve AI whenever the website changes and your automation breaks.
Getting Started
Start with Stagehand with one line of code, or check out our Quickstart Guide for more information:
npx create-browser-app
Example
Here's how to build a sample browser automation with Stagehand:
// Stagehand's CDP engine provides an optimized, low level interface to the browser built for automation
const page = stagehand.context.pages()[0];
await page.goto("https://github.com/browserbase");
// Use act() to execute individual actions
await stagehand.act("click on the stagehand repo");
// Use agent() for multi-step tasks
const agent = stagehand.agent();
await agent.execute("Get to the latest PR");
// Use extract() to get structured data from the page
const { author, title } = await stagehand.extract(
"extract the author and title of the PR",
z.object({
author: z.string().describe("The username of the PR author"),
title: z.string().describe("The title of the PR"),
}),
);
Documentation
Visit docs.stagehand.dev to view the full documentation.
Build and Run from Source
git clone https://github.com/browserbase/stagehand.git
cd stagehand
pnpm install
pnpm run build
pnpm run example # run the blank script at ./examples/example.ts
Stagehand is best when you have an API key for an LLM provider and Browserbase credentials. To add these to your project, run:
cp .env.example .env
nano .env # Edit the .env file to add API keys
Installing from a branch
You can install and build Stagehand directly from a github branch using gitpkg
In your project's package.json set:
"@browserbasehq/stagehand": "https://gitpkg.now.sh/browserbase/stagehand/packages/core?<branchName>",
Contributing
Note
We highly value contributions to Stagehand! For questions or support, please join our Discord community.
At a high level, we're focused on improving reliability, extensibility, speed, and cost in that order of priority. If you're interested in contributing, bug fixes and small improvements are the best way to get started. For more involved features, we strongly recommend reaching out to Miguel Gonzalez or Paul Klein in our Discord community before starting to ensure that your contribution aligns with our goals.
Acknowledgements
We'd like to thank the following people for their major contributions to Stagehand:
- Paul Klein
- Sean McGuire
- Miguel Gonzalez
- Sameel Arif
- Thomas Katwan
- Filip Michalsky
- Anirudh Kamath
- Jeremy Press
- Navid Pour
License
Licensed under the MIT License.
Copyright 2025 Browserbase, Inc.