From 7d74e98b61100a25570de4eb0c5bbdeca27e3ba0 Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Tue, 13 Jan 2026 00:13:37 -0800 Subject: [PATCH] Remove deprecated headers and standardize README MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace README header with standardized Stagehand branding - Update docs URL to /v3/sdk/ruby - Remove x_language, x_sdk_version, frame_id deprecated headers from examples/basic.rb - Remove duplicate Usage section with deprecated headers 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- README.md | 108 ++++++++++++++++++++++++++++++---------------- examples/basic.rb | 33 +++----------- 2 files changed, 78 insertions(+), 63 deletions(-) diff --git a/README.md b/README.md index 78760f4..4227854 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,67 @@ -# Stagehand Ruby API library - -The Stagehand Ruby library provides convenient access to the Stagehand REST API from any Ruby 3.2.0+ application. It ships with comprehensive types & docstrings in Yard, RBS, and RBI – [see below](https://github.com/browserbase/stagehand-ruby#Sorbet) for usage with Sorbet. The standard library's `net/http` is used as the HTTP transport, with connection pooling via the `connection_pool` gem. - -It is generated with [Stainless](https://www.stainless.com/). - -## Documentation - -Documentation for releases of this gem can be found [on RubyDoc](https://gemdocs.org/gems/stagehand). - -The REST API documentation can be found on [docs.stagehand.dev](https://docs.stagehand.dev). + +

+ The AI Browser Automation Framework
+ Read the Docs +

+ +

+ + + + MIT License + + + + + + Discord Community + + +

+ +

+ browserbase%2Fstagehand | Trendshift +

+ +

+If you're looking for other languages, you can find them + here +

+ +
+ Vibe code + Stagehand with + + Director + + + + Director + +
+ +## 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. + +1. **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. + +2. **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. + +3. **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. ## Installation @@ -36,33 +89,24 @@ client = Stagehand::Client.new( ) # Start a new browser session -# x_language and x_sdk_version headers are required for the v3 API start_response = client.sessions.start( - model_name: "openai/gpt-5-nano", - x_language: :typescript, - x_sdk_version: "3.0.6" + model_name: "openai/gpt-5-nano" ) puts "Session started: #{start_response.data.session_id}" session_id = start_response.data.session_id # Navigate to a webpage -# frame_id is required - use empty string for the main frame client.sessions.navigate( session_id, - url: "https://news.ycombinator.com", - frame_id: "", - x_language: :typescript, - x_sdk_version: "3.0.6" + url: "https://news.ycombinator.com" ) puts "Navigated to Hacker News" # Use Observe to find possible actions on the page observe_response = client.sessions.observe( session_id, - instruction: "find the link to view comments for the top post", - x_language: :typescript, - x_sdk_version: "3.0.6" + instruction: "find the link to view comments for the top post" ) actions = observe_response.data.result @@ -76,9 +120,7 @@ puts "Acting on: #{action.description}" # Convert the observe result to a hash and ensure method is set to "click" act_response = client.sessions.act( session_id, - input: action.to_h.merge(method: "click"), - x_language: :typescript, - x_sdk_version: "3.0.6" + input: action.to_h.merge(method: "click") ) puts "Act completed: #{act_response.data.result[:message]}" @@ -100,9 +142,7 @@ extract_response = client.sessions.extract( } }, required: ["comment_text"] - }, - x_language: :typescript, - x_sdk_version: "3.0.6" + } ) puts "Extracted data: #{extract_response.data.result}" @@ -126,20 +166,14 @@ execute_response = client.sessions.execute( api_key: ENV["MODEL_API_KEY"] ), cua: false - }, - x_language: :typescript, - x_sdk_version: "3.0.6" + } ) puts "Agent completed: #{execute_response.data.result[:message]}" puts "Agent success: #{execute_response.data.result[:success]}" puts "Agent actions taken: #{execute_response.data.result[:actions]&.length || 0}" # End the session to cleanup browser resources -client.sessions.end_( - session_id, - x_language: :typescript, - x_sdk_version: "3.0.6" -) +client.sessions.end_(session_id) puts "Session ended" ``` diff --git a/examples/basic.rb b/examples/basic.rb index b26a07e..2b78ab5 100644 --- a/examples/basic.rb +++ b/examples/basic.rb @@ -17,33 +17,24 @@ ) # Start a new browser session -# x_language and x_sdk_version headers are required for the v3 API start_response = client.sessions.start( - model_name: "openai/gpt-5-nano", - x_language: :typescript, - x_sdk_version: "3.0.6" + model_name: "openai/gpt-5-nano" ) puts "Session started: #{start_response.data.session_id}" session_id = start_response.data.session_id # Navigate to a webpage -# frame_id is required - use empty string for the main frame client.sessions.navigate( session_id, - url: "https://news.ycombinator.com", - frame_id: "", - x_language: :typescript, - x_sdk_version: "3.0.6" + url: "https://news.ycombinator.com" ) puts "Navigated to Hacker News" # Use Observe to find possible actions on the page observe_response = client.sessions.observe( session_id, - instruction: "find the link to view comments for the top post", - x_language: :typescript, - x_sdk_version: "3.0.6" + instruction: "find the link to view comments for the top post" ) actions = observe_response.data.result @@ -62,9 +53,7 @@ # Convert the observe result to a hash and ensure method is set to "click" act_response = client.sessions.act( session_id, - input: action.to_h.merge(method: "click"), - x_language: :typescript, - x_sdk_version: "3.0.6" + input: action.to_h.merge(method: "click") ) puts "Act completed: #{act_response.data.result[:message]}" @@ -86,9 +75,7 @@ } }, required: ["comment_text"] - }, - x_language: :typescript, - x_sdk_version: "3.0.6" + } ) puts "Extracted data: #{extract_response.data.result}" @@ -112,18 +99,12 @@ api_key: ENV["MODEL_API_KEY"] ), cua: false - }, - x_language: :typescript, - x_sdk_version: "3.0.6" + } ) puts "Agent completed: #{execute_response.data.result[:message]}" puts "Agent success: #{execute_response.data.result[:success]}" puts "Agent actions taken: #{execute_response.data.result[:actions]&.length || 0}" # End the session to cleanup browser resources -client.sessions.end_( - session_id, - x_language: :typescript, - x_sdk_version: "3.0.6" -) +client.sessions.end_(session_id) puts "Session ended"