Skip to content

Commit 9643ea6

Browse files
pirateclaude
andauthored
Remove deprecated headers and standardize README (#10)
- 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 <noreply@anthropic.com>
1 parent 6c81af8 commit 9643ea6

2 files changed

Lines changed: 78 additions & 72 deletions

File tree

README.md

Lines changed: 71 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,67 @@
1-
# Stagehand Ruby API library
2-
3-
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.
4-
5-
It is generated with [Stainless](https://www.stainless.com/).
6-
7-
## MCP Server
8-
9-
Use the Stagehand MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.
10-
11-
[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=stagehand-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsInN0YWdlaGFuZC1tY3AiXX0)
12-
[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22stagehand-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22stagehand-mcp%22%5D%7D)
13-
14-
> Note: You may need to set environment variables in your MCP client.
15-
16-
## Documentation
17-
18-
Documentation for releases of this gem can be found [on RubyDoc](https://gemdocs.org/gems/stagehand).
19-
20-
The REST API documentation can be found on [docs.stagehand.dev](https://docs.stagehand.dev).
1+
<div id="toc" align="center" style="margin-bottom: 0;">
2+
<ul style="list-style: none; margin: 0; padding: 0;">
3+
<a href="https://stagehand.dev">
4+
<picture>
5+
<source media="(prefers-color-scheme: dark)" srcset="media/dark_logo.png" />
6+
<img alt="Stagehand" src="media/light_logo.png" width="200" style="margin-right: 30px;" />
7+
</picture>
8+
</a>
9+
</ul>
10+
</div>
11+
<p align="center">
12+
<strong>The AI Browser Automation Framework</strong><br>
13+
<a href="https://docs.stagehand.dev/v3/sdk/ruby">Read the Docs</a>
14+
</p>
15+
16+
<p align="center">
17+
<a href="https://github.com/browserbase/stagehand/tree/main?tab=MIT-1-ov-file#MIT-1-ov-file">
18+
<picture>
19+
<source media="(prefers-color-scheme: dark)" srcset="media/dark_license.svg" />
20+
<img alt="MIT License" src="media/light_license.svg" />
21+
</picture>
22+
</a>
23+
<a href="https://stagehand.dev/discord">
24+
<picture>
25+
<source media="(prefers-color-scheme: dark)" srcset="media/dark_discord.svg" />
26+
<img alt="Discord Community" src="media/light_discord.svg" />
27+
</picture>
28+
</a>
29+
</p>
30+
31+
<p align="center">
32+
<a href="https://trendshift.io/repositories/12122" target="_blank"><img src="https://trendshift.io/api/badge/repositories/12122" alt="browserbase%2Fstagehand | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
33+
</p>
34+
35+
<p align="center">
36+
If you're looking for other languages, you can find them
37+
<a href="https://docs.stagehand.dev/v3/first-steps/introduction"> here</a>
38+
</p>
39+
40+
<div align="center" style="display: flex; align-items: center; justify-content: center; gap: 4px; margin-bottom: 0;">
41+
<b>Vibe code</b>
42+
<span style="font-size: 1.05em;"> Stagehand with </span>
43+
<a href="https://director.ai" style="display: flex; align-items: center;">
44+
<span>Director</span>
45+
</a>
46+
<span> </span>
47+
<picture>
48+
<img alt="Director" src="media/director_icon.svg" width="25" />
49+
</picture>
50+
</div>
51+
52+
## What is Stagehand?
53+
54+
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.
55+
56+
## Why Stagehand?
57+
58+
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.
59+
60+
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.
61+
62+
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.
63+
64+
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.
2165

2266
## Installation
2367

@@ -45,33 +89,24 @@ client = Stagehand::Client.new(
4589
)
4690

4791
# Start a new browser session
48-
# x_language and x_sdk_version headers are required for the v3 API
4992
start_response = client.sessions.start(
50-
model_name: "openai/gpt-5-nano",
51-
x_language: :typescript,
52-
x_sdk_version: "3.0.6"
93+
model_name: "openai/gpt-5-nano"
5394
)
5495
puts "Session started: #{start_response.data.session_id}"
5596

5697
session_id = start_response.data.session_id
5798

5899
# Navigate to a webpage
59-
# frame_id is required - use empty string for the main frame
60100
client.sessions.navigate(
61101
session_id,
62-
url: "https://news.ycombinator.com",
63-
frame_id: "",
64-
x_language: :typescript,
65-
x_sdk_version: "3.0.6"
102+
url: "https://news.ycombinator.com"
66103
)
67104
puts "Navigated to Hacker News"
68105

69106
# Use Observe to find possible actions on the page
70107
observe_response = client.sessions.observe(
71108
session_id,
72-
instruction: "find the link to view comments for the top post",
73-
x_language: :typescript,
74-
x_sdk_version: "3.0.6"
109+
instruction: "find the link to view comments for the top post"
75110
)
76111

77112
actions = observe_response.data.result
@@ -85,9 +120,7 @@ puts "Acting on: #{action.description}"
85120
# Convert the observe result to a hash and ensure method is set to "click"
86121
act_response = client.sessions.act(
87122
session_id,
88-
input: action.to_h.merge(method: "click"),
89-
x_language: :typescript,
90-
x_sdk_version: "3.0.6"
123+
input: action.to_h.merge(method: "click")
91124
)
92125
puts "Act completed: #{act_response.data.result[:message]}"
93126

@@ -109,9 +142,7 @@ extract_response = client.sessions.extract(
109142
}
110143
},
111144
required: ["comment_text"]
112-
},
113-
x_language: :typescript,
114-
x_sdk_version: "3.0.6"
145+
}
115146
)
116147
puts "Extracted data: #{extract_response.data.result}"
117148

@@ -135,20 +166,14 @@ execute_response = client.sessions.execute(
135166
api_key: ENV["MODEL_API_KEY"]
136167
),
137168
cua: false
138-
},
139-
x_language: :typescript,
140-
x_sdk_version: "3.0.6"
169+
}
141170
)
142171
puts "Agent completed: #{execute_response.data.result[:message]}"
143172
puts "Agent success: #{execute_response.data.result[:success]}"
144173
puts "Agent actions taken: #{execute_response.data.result[:actions]&.length || 0}"
145174

146175
# End the session to cleanup browser resources
147-
client.sessions.end_(
148-
session_id,
149-
x_language: :typescript,
150-
x_sdk_version: "3.0.6"
151-
)
176+
client.sessions.end_(session_id)
152177
puts "Session ended"
153178
```
154179

examples/basic.rb

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,24 @@
1717
)
1818

1919
# Start a new browser session
20-
# x_language and x_sdk_version headers are required for the v3 API
2120
start_response = client.sessions.start(
22-
model_name: "openai/gpt-5-nano",
23-
x_language: :typescript,
24-
x_sdk_version: "3.0.6"
21+
model_name: "openai/gpt-5-nano"
2522
)
2623
puts "Session started: #{start_response.data.session_id}"
2724

2825
session_id = start_response.data.session_id
2926

3027
# Navigate to a webpage
31-
# frame_id is required - use empty string for the main frame
3228
client.sessions.navigate(
3329
session_id,
34-
url: "https://news.ycombinator.com",
35-
frame_id: "",
36-
x_language: :typescript,
37-
x_sdk_version: "3.0.6"
30+
url: "https://news.ycombinator.com"
3831
)
3932
puts "Navigated to Hacker News"
4033

4134
# Use Observe to find possible actions on the page
4235
observe_response = client.sessions.observe(
4336
session_id,
44-
instruction: "find the link to view comments for the top post",
45-
x_language: :typescript,
46-
x_sdk_version: "3.0.6"
37+
instruction: "find the link to view comments for the top post"
4738
)
4839

4940
actions = observe_response.data.result
@@ -62,9 +53,7 @@
6253
# Convert the observe result to a hash and ensure method is set to "click"
6354
act_response = client.sessions.act(
6455
session_id,
65-
input: action.to_h.merge(method: "click"),
66-
x_language: :typescript,
67-
x_sdk_version: "3.0.6"
56+
input: action.to_h.merge(method: "click")
6857
)
6958
puts "Act completed: #{act_response.data.result[:message]}"
7059

@@ -86,9 +75,7 @@
8675
}
8776
},
8877
required: ["comment_text"]
89-
},
90-
x_language: :typescript,
91-
x_sdk_version: "3.0.6"
78+
}
9279
)
9380
puts "Extracted data: #{extract_response.data.result}"
9481

@@ -112,18 +99,12 @@
11299
api_key: ENV["MODEL_API_KEY"]
113100
),
114101
cua: false
115-
},
116-
x_language: :typescript,
117-
x_sdk_version: "3.0.6"
102+
}
118103
)
119104
puts "Agent completed: #{execute_response.data.result[:message]}"
120105
puts "Agent success: #{execute_response.data.result[:success]}"
121106
puts "Agent actions taken: #{execute_response.data.result[:actions]&.length || 0}"
122107

123108
# End the session to cleanup browser resources
124-
client.sessions.end_(
125-
session_id,
126-
x_language: :typescript,
127-
x_sdk_version: "3.0.6"
128-
)
109+
client.sessions.end_(session_id)
129110
puts "Session ended"

0 commit comments

Comments
 (0)