stagehand 3.5.2 → 3.6.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +135 -126
- data/lib/stagehand/models/session_replay_response.rb +61 -19
- data/lib/stagehand/version.rb +1 -1
- data/rbi/stagehand/models/session_replay_response.rbi +71 -54
- data/sig/stagehand/models/session_replay_response.rbs +58 -29
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 50f660b2c567e5cc200d36aedaebafd5de79c1d41f9402a73a5f7c1ebb539f8a
|
|
4
|
+
data.tar.gz: 70f5dd300c85f94fd3ef9e6e083bb12e6469d6cb2dce31e08d8e1610e532618f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 955bb2a558c4167c28d8ea9d14ba9fe0ba4b520d9828018faa57c0ea3795535214d4838f9010ffab06c3553469ceb518ce7a11d2bac35ab6f7b3d9b81db9457b
|
|
7
|
+
data.tar.gz: fd0464bc25e63eeb06c9799631d527fe5239214024eab2f2faef41a556716644c460f517d250470659c53dd3d69e21f100beda01f21e4bef548ac3bbee94865b
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.6.0 (2026-02-18)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v3.5.2...v3.6.0](https://github.com/browserbase/stagehand-ruby/compare/v3.5.2...v3.6.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* randomize region used for evals, split out pnpm and turbo cache, veri… ([a68a9d2](https://github.com/browserbase/stagehand-ruby/commit/a68a9d2705b2c3b3b35dcaab4b5693184194774b))
|
|
10
|
+
|
|
3
11
|
## 3.5.2 (2026-02-07)
|
|
4
12
|
|
|
5
13
|
Full Changelog: [v3.5.1...v3.5.2](https://github.com/browserbase/stagehand-ruby/compare/v3.5.1...v3.5.2)
|
data/README.md
CHANGED
|
@@ -1,5 +1,58 @@
|
|
|
1
1
|
# Stagehand Ruby API library
|
|
2
2
|
|
|
3
|
+
<!-- x-stagehand-custom-start -->
|
|
4
|
+
<div id="toc" align="center" style="margin-bottom: 0;">
|
|
5
|
+
<ul style="list-style: none; margin: 0; padding: 0;">
|
|
6
|
+
<a href="https://stagehand.dev">
|
|
7
|
+
<picture>
|
|
8
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/browserbase/stagehand/main/media/dark_logo.png" />
|
|
9
|
+
<img alt="Stagehand" src="https://raw.githubusercontent.com/browserbase/stagehand/main/media/light_logo.png" width="200" style="margin-right: 30px;" />
|
|
10
|
+
</picture>
|
|
11
|
+
</a>
|
|
12
|
+
</ul>
|
|
13
|
+
</div>
|
|
14
|
+
<p align="center">
|
|
15
|
+
<strong>The AI Browser Automation Framework</strong><br>
|
|
16
|
+
<a href="https://docs.stagehand.dev/v3/sdk/ruby">Read the Docs</a>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<p align="center">
|
|
20
|
+
<a href="https://github.com/browserbase/stagehand/tree/main?tab=MIT-1-ov-file#MIT-1-ov-file">
|
|
21
|
+
<picture>
|
|
22
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/browserbase/stagehand/main/media/dark_license.svg" />
|
|
23
|
+
<img alt="MIT License" src="https://raw.githubusercontent.com/browserbase/stagehand/main/media/light_license.svg" />
|
|
24
|
+
</picture>
|
|
25
|
+
</a>
|
|
26
|
+
<a href="https://stagehand.dev/discord">
|
|
27
|
+
<picture>
|
|
28
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/browserbase/stagehand/main/media/dark_discord.svg" />
|
|
29
|
+
<img alt="Discord Community" src="https://raw.githubusercontent.com/browserbase/stagehand/main/media/light_discord.svg" />
|
|
30
|
+
</picture>
|
|
31
|
+
</a>
|
|
32
|
+
</p>
|
|
33
|
+
|
|
34
|
+
<p align="center">
|
|
35
|
+
<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>
|
|
36
|
+
</p>
|
|
37
|
+
|
|
38
|
+
<p align="center">
|
|
39
|
+
If you're looking for other languages, you can find them
|
|
40
|
+
<a href="https://docs.stagehand.dev/v3/first-steps/introduction"> here</a>
|
|
41
|
+
</p>
|
|
42
|
+
|
|
43
|
+
<div align="center" style="display: flex; align-items: center; justify-content: center; gap: 4px; margin-bottom: 0;">
|
|
44
|
+
<b>Vibe code</b>
|
|
45
|
+
<span style="font-size: 1.05em;"> Stagehand with </span>
|
|
46
|
+
<a href="https://director.ai" style="display: flex; align-items: center;">
|
|
47
|
+
<span>Director</span>
|
|
48
|
+
</a>
|
|
49
|
+
<span> </span>
|
|
50
|
+
<picture>
|
|
51
|
+
<img alt="Director" src="https://raw.githubusercontent.com/browserbase/stagehand/main/media/director_icon.svg" width="25" />
|
|
52
|
+
</picture>
|
|
53
|
+
</div>
|
|
54
|
+
<!-- x-stagehand-custom-end -->
|
|
55
|
+
|
|
3
56
|
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
57
|
|
|
5
58
|
It is generated with [Stainless](https://www.stainless.com/).
|
|
@@ -24,163 +77,119 @@ gem "stagehand", :git => "git://github.com/browserbase/stagehand-ruby.git"
|
|
|
24
77
|
|
|
25
78
|
## Usage
|
|
26
79
|
|
|
80
|
+
This mirrors `examples/remote_browser_playwright_example.rb`.
|
|
81
|
+
|
|
27
82
|
```ruby
|
|
28
83
|
require "bundler/setup"
|
|
29
84
|
require "stagehand"
|
|
30
85
|
|
|
31
|
-
|
|
86
|
+
require_relative "examples/env"
|
|
87
|
+
ExampleEnv.load!
|
|
88
|
+
|
|
89
|
+
require "playwright"
|
|
90
|
+
|
|
32
91
|
client = Stagehand::Client.new(
|
|
33
|
-
browserbase_api_key: ENV["BROWSERBASE_API_KEY"],
|
|
34
|
-
browserbase_project_id: ENV["BROWSERBASE_PROJECT_ID"],
|
|
35
|
-
model_api_key: ENV["MODEL_API_KEY"]
|
|
92
|
+
browserbase_api_key: ENV["BROWSERBASE_API_KEY"],
|
|
93
|
+
browserbase_project_id: ENV["BROWSERBASE_PROJECT_ID"],
|
|
94
|
+
model_api_key: ENV["MODEL_API_KEY"],
|
|
95
|
+
server: "remote"
|
|
36
96
|
)
|
|
37
97
|
|
|
38
|
-
# Start a new browser session
|
|
39
98
|
start_response = client.sessions.start(
|
|
40
|
-
model_name: "
|
|
99
|
+
model_name: "anthropic/claude-sonnet-4-6",
|
|
100
|
+
browser: { type: :browserbase }
|
|
41
101
|
)
|
|
42
|
-
puts "Session started: #{start_response.data.session_id}"
|
|
43
102
|
|
|
44
103
|
session_id = start_response.data.session_id
|
|
104
|
+
cdp_url = start_response.data.cdp_url
|
|
105
|
+
raise "No CDP URL returned for this session." if cdp_url.to_s.empty?
|
|
45
106
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
)
|
|
51
|
-
puts "Navigated to Hacker News"
|
|
107
|
+
Playwright.create(playwright_cli_executable_path: "./node_modules/.bin/playwright") do |playwright|
|
|
108
|
+
browser = playwright.chromium.connect_over_cdp(cdp_url)
|
|
109
|
+
context = browser.contexts.first || browser.new_context
|
|
110
|
+
page = context.pages.first || context.new_page
|
|
52
111
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
session_id,
|
|
56
|
-
instruction: "find the link to view comments for the top post"
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
actions = observe_response.data.result
|
|
60
|
-
puts "Found #{actions.length} possible actions"
|
|
112
|
+
client.sessions.navigate(session_id, url: "https://news.ycombinator.com")
|
|
113
|
+
page.wait_for_load_state(state: "domcontentloaded")
|
|
61
114
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
115
|
+
observe_stream = client.sessions.observe_streaming(
|
|
116
|
+
session_id,
|
|
117
|
+
instruction: "find the link to view comments for the top post"
|
|
118
|
+
)
|
|
119
|
+
observe_stream.each { |_event| }
|
|
65
120
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
type: "object",
|
|
81
|
-
properties: {
|
|
82
|
-
comment_text: {
|
|
83
|
-
type: "string",
|
|
84
|
-
description: "The text content of the top comment"
|
|
121
|
+
act_stream = client.sessions.act_streaming(
|
|
122
|
+
session_id,
|
|
123
|
+
input: "Click the comments link for the top post"
|
|
124
|
+
)
|
|
125
|
+
act_stream.each { |_event| }
|
|
126
|
+
|
|
127
|
+
extract_stream = client.sessions.extract_streaming(
|
|
128
|
+
session_id,
|
|
129
|
+
instruction: "extract the text of the top comment on this page",
|
|
130
|
+
schema: {
|
|
131
|
+
type: "object",
|
|
132
|
+
properties: {
|
|
133
|
+
commentText: {type: "string"},
|
|
134
|
+
author: {type: "string"}
|
|
85
135
|
},
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
136
|
+
required: ["commentText"]
|
|
137
|
+
}
|
|
138
|
+
)
|
|
139
|
+
extract_stream.each { |_event| }
|
|
140
|
+
|
|
141
|
+
execute_stream = client.sessions.execute_streaming(
|
|
142
|
+
session_id,
|
|
143
|
+
execute_options: {
|
|
144
|
+
instruction: "Click the 'Learn more' link if available",
|
|
145
|
+
max_steps: 3
|
|
90
146
|
},
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
# Use the Agent to find the author's profile
|
|
102
|
-
# Execute runs an autonomous agent that can navigate and interact with pages
|
|
103
|
-
execute_response = client.sessions.execute(
|
|
104
|
-
session_id,
|
|
105
|
-
execute_options: {
|
|
106
|
-
instruction: "Find any personal website, GitHub, LinkedIn, or other best profile URL for the Hacker News user '#{author}'. " \
|
|
107
|
-
"Click on their username to go to their profile page and look for any links they have shared.",
|
|
108
|
-
max_steps: 15
|
|
109
|
-
},
|
|
110
|
-
agent_config: {
|
|
111
|
-
model: Stagehand::ModelConfig::ModelConfigObject.new(
|
|
112
|
-
model_name: "openai/gpt-5-nano",
|
|
113
|
-
api_key: ENV["MODEL_API_KEY"]
|
|
114
|
-
),
|
|
115
|
-
cua: false
|
|
116
|
-
}
|
|
117
|
-
)
|
|
118
|
-
puts "Agent completed: #{execute_response.data.result[:message]}"
|
|
119
|
-
puts "Agent success: #{execute_response.data.result[:success]}"
|
|
120
|
-
puts "Agent actions taken: #{execute_response.data.result[:actions]&.length || 0}"
|
|
147
|
+
agent_config: {
|
|
148
|
+
model: Stagehand::ModelConfig.new(
|
|
149
|
+
model_name: "anthropic/claude-opus-4-6",
|
|
150
|
+
api_key: ENV["MODEL_API_KEY"]
|
|
151
|
+
),
|
|
152
|
+
cua: false
|
|
153
|
+
}
|
|
154
|
+
)
|
|
155
|
+
execute_stream.each { |_event| }
|
|
156
|
+
end
|
|
121
157
|
|
|
122
|
-
# End the session to cleanup browser resources
|
|
123
158
|
client.sessions.end_(session_id)
|
|
124
|
-
puts "Session ended"
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
### Running the Examples
|
|
128
|
-
|
|
129
|
-
Install dependencies, set credentials, and run the scripts below.
|
|
130
|
-
|
|
131
|
-
```bash
|
|
132
|
-
# Install the gem dependencies
|
|
133
|
-
bundle install
|
|
134
159
|
```
|
|
135
160
|
|
|
136
|
-
|
|
161
|
+
## Running the Example
|
|
137
162
|
|
|
138
|
-
|
|
139
|
-
export BROWSERBASE_API_KEY="your-browserbase-api-key"
|
|
140
|
-
export BROWSERBASE_PROJECT_ID="your-browserbase-project-id"
|
|
141
|
-
export MODEL_API_KEY="your-openai-api-key"
|
|
142
|
-
bundle exec ruby examples/remote_browser_example.rb
|
|
143
|
-
```
|
|
163
|
+
Set your environment variables (from `examples/.env.example`):
|
|
144
164
|
|
|
145
|
-
|
|
165
|
+
- `STAGEHAND_API_URL`
|
|
166
|
+
- `MODEL_API_KEY`
|
|
167
|
+
- `BROWSERBASE_API_KEY`
|
|
168
|
+
- `BROWSERBASE_PROJECT_ID`
|
|
146
169
|
|
|
147
170
|
```bash
|
|
148
|
-
|
|
149
|
-
|
|
171
|
+
cp examples/.env.example examples/.env
|
|
172
|
+
# Edit examples/.env with your credentials.
|
|
150
173
|
```
|
|
151
174
|
|
|
152
|
-
|
|
175
|
+
The examples load `examples/.env` automatically.
|
|
153
176
|
|
|
154
|
-
|
|
155
|
-
gem install playwright-ruby-client
|
|
156
|
-
npm install playwright
|
|
157
|
-
./node_modules/.bin/playwright install chromium
|
|
158
|
-
export MODEL_API_KEY="your-openai-api-key"
|
|
159
|
-
bundle exec ruby examples/local_playwright_example.rb
|
|
177
|
+
Examples and dependencies:
|
|
160
178
|
|
|
161
|
-
|
|
162
|
-
|
|
179
|
+
- `examples/remote_browser_example.rb`: stagehand only
|
|
180
|
+
- `examples/local_browser_example.rb`: stagehand only
|
|
181
|
+
- `examples/remote_browser_playwright_example.rb`: `playwright-ruby-client` + Playwright browsers
|
|
182
|
+
- `examples/local_browser_playwright_example.rb`: `playwright-ruby-client` + Playwright browsers
|
|
183
|
+
- `examples/local_playwright_example.rb`: `playwright-ruby-client` + Playwright browsers
|
|
184
|
+
- `examples/local_watir_example.rb`: `watir`
|
|
163
185
|
|
|
164
|
-
|
|
186
|
+
Install dependencies for the example you want to run, then execute it:
|
|
165
187
|
|
|
166
188
|
```bash
|
|
167
|
-
|
|
168
|
-
npm install playwright
|
|
169
|
-
./node_modules/.bin/playwright install chromium
|
|
170
|
-
export BROWSERBASE_API_KEY="your-browserbase-api-key"
|
|
171
|
-
export BROWSERBASE_PROJECT_ID="your-browserbase-project-id"
|
|
172
|
-
export MODEL_API_KEY="your-openai-api-key"
|
|
189
|
+
bundle install
|
|
173
190
|
bundle exec ruby examples/remote_browser_playwright_example.rb
|
|
174
191
|
```
|
|
175
192
|
|
|
176
|
-
Watir local example:
|
|
177
|
-
|
|
178
|
-
```bash
|
|
179
|
-
gem install watir
|
|
180
|
-
export MODEL_API_KEY="your-openai-api-key"
|
|
181
|
-
bundle exec ruby examples/local_watir_example.rb
|
|
182
|
-
```
|
|
183
|
-
|
|
184
193
|
### Streaming
|
|
185
194
|
|
|
186
195
|
We provide support for streaming responses using Server-Sent Events (SSE).
|
|
@@ -202,7 +211,7 @@ When the library is unable to connect to the API, or if the API returns a non-su
|
|
|
202
211
|
|
|
203
212
|
```ruby
|
|
204
213
|
begin
|
|
205
|
-
session = stagehand.sessions.start(model_name: "
|
|
214
|
+
session = stagehand.sessions.start(model_name: "anthropic/claude-sonnet-4-6")
|
|
206
215
|
rescue Stagehand::Errors::APIConnectionError => e
|
|
207
216
|
puts("The server could not be reached")
|
|
208
217
|
puts(e.cause) # an underlying Exception, likely raised within `net/http`
|
|
@@ -245,7 +254,7 @@ stagehand = Stagehand::Client.new(
|
|
|
245
254
|
)
|
|
246
255
|
|
|
247
256
|
# Or, configure per-request:
|
|
248
|
-
stagehand.sessions.start(model_name: "
|
|
257
|
+
stagehand.sessions.start(model_name: "anthropic/claude-sonnet-4-6", request_options: {max_retries: 5})
|
|
249
258
|
```
|
|
250
259
|
|
|
251
260
|
### Timeouts
|
|
@@ -259,7 +268,7 @@ stagehand = Stagehand::Client.new(
|
|
|
259
268
|
)
|
|
260
269
|
|
|
261
270
|
# Or, configure per-request:
|
|
262
|
-
stagehand.sessions.start(model_name: "
|
|
271
|
+
stagehand.sessions.start(model_name: "anthropic/claude-sonnet-4-6", request_options: {timeout: 5})
|
|
263
272
|
```
|
|
264
273
|
|
|
265
274
|
On timeout, `Stagehand::Errors::APITimeoutError` is raised.
|
|
@@ -291,7 +300,7 @@ Note: the `extra_` parameters of the same name overrides the documented paramete
|
|
|
291
300
|
```ruby
|
|
292
301
|
response =
|
|
293
302
|
stagehand.sessions.start(
|
|
294
|
-
model_name: "
|
|
303
|
+
model_name: "anthropic/claude-sonnet-4-6",
|
|
295
304
|
request_options: {
|
|
296
305
|
extra_query: {my_query_parameter: value},
|
|
297
306
|
extra_body: {my_body_parameter: value},
|
|
@@ -24,28 +24,72 @@ module Stagehand
|
|
|
24
24
|
class Data < Stagehand::Internal::Type::BaseModel
|
|
25
25
|
# @!attribute pages
|
|
26
26
|
#
|
|
27
|
-
# @return [Array<Stagehand::Models::SessionReplayResponse::Data::Page
|
|
28
|
-
|
|
27
|
+
# @return [Array<Stagehand::Models::SessionReplayResponse::Data::Page>]
|
|
28
|
+
required :pages,
|
|
29
29
|
-> { Stagehand::Internal::Type::ArrayOf[Stagehand::Models::SessionReplayResponse::Data::Page] }
|
|
30
30
|
|
|
31
|
-
# @!
|
|
31
|
+
# @!attribute client_language
|
|
32
|
+
#
|
|
33
|
+
# @return [String, nil]
|
|
34
|
+
optional :client_language, String, api_name: :clientLanguage
|
|
35
|
+
|
|
36
|
+
# @!method initialize(pages:, client_language: nil)
|
|
32
37
|
# @param pages [Array<Stagehand::Models::SessionReplayResponse::Data::Page>]
|
|
38
|
+
# @param client_language [String]
|
|
33
39
|
|
|
34
40
|
class Page < Stagehand::Internal::Type::BaseModel
|
|
35
41
|
# @!attribute actions
|
|
36
42
|
#
|
|
37
|
-
# @return [Array<Stagehand::Models::SessionReplayResponse::Data::Page::Action
|
|
38
|
-
|
|
43
|
+
# @return [Array<Stagehand::Models::SessionReplayResponse::Data::Page::Action>]
|
|
44
|
+
required :actions,
|
|
39
45
|
-> { Stagehand::Internal::Type::ArrayOf[Stagehand::Models::SessionReplayResponse::Data::Page::Action] }
|
|
40
46
|
|
|
41
|
-
# @!
|
|
47
|
+
# @!attribute duration
|
|
48
|
+
#
|
|
49
|
+
# @return [Float]
|
|
50
|
+
required :duration, Float
|
|
51
|
+
|
|
52
|
+
# @!attribute timestamp
|
|
53
|
+
#
|
|
54
|
+
# @return [Float]
|
|
55
|
+
required :timestamp, Float
|
|
56
|
+
|
|
57
|
+
# @!attribute url
|
|
58
|
+
#
|
|
59
|
+
# @return [String]
|
|
60
|
+
required :url, String
|
|
61
|
+
|
|
62
|
+
# @!method initialize(actions:, duration:, timestamp:, url:)
|
|
42
63
|
# @param actions [Array<Stagehand::Models::SessionReplayResponse::Data::Page::Action>]
|
|
64
|
+
# @param duration [Float]
|
|
65
|
+
# @param timestamp [Float]
|
|
66
|
+
# @param url [String]
|
|
43
67
|
|
|
44
68
|
class Action < Stagehand::Internal::Type::BaseModel
|
|
45
69
|
# @!attribute method_
|
|
46
70
|
#
|
|
47
|
-
# @return [String
|
|
48
|
-
|
|
71
|
+
# @return [String]
|
|
72
|
+
required :method_, String, api_name: :method
|
|
73
|
+
|
|
74
|
+
# @!attribute parameters
|
|
75
|
+
#
|
|
76
|
+
# @return [Hash{Symbol=>Object}]
|
|
77
|
+
required :parameters, Stagehand::Internal::Type::HashOf[Stagehand::Internal::Type::Unknown]
|
|
78
|
+
|
|
79
|
+
# @!attribute result
|
|
80
|
+
#
|
|
81
|
+
# @return [Hash{Symbol=>Object}]
|
|
82
|
+
required :result, Stagehand::Internal::Type::HashOf[Stagehand::Internal::Type::Unknown]
|
|
83
|
+
|
|
84
|
+
# @!attribute timestamp
|
|
85
|
+
#
|
|
86
|
+
# @return [Float]
|
|
87
|
+
required :timestamp, Float
|
|
88
|
+
|
|
89
|
+
# @!attribute end_time
|
|
90
|
+
#
|
|
91
|
+
# @return [Float, nil]
|
|
92
|
+
optional :end_time, Float, api_name: :endTime
|
|
49
93
|
|
|
50
94
|
# @!attribute token_usage
|
|
51
95
|
#
|
|
@@ -54,16 +98,20 @@ module Stagehand
|
|
|
54
98
|
-> { Stagehand::Models::SessionReplayResponse::Data::Page::Action::TokenUsage },
|
|
55
99
|
api_name: :tokenUsage
|
|
56
100
|
|
|
57
|
-
# @!method initialize(method_: nil, token_usage: nil)
|
|
101
|
+
# @!method initialize(method_:, parameters:, result:, timestamp:, end_time: nil, token_usage: nil)
|
|
58
102
|
# @param method_ [String]
|
|
103
|
+
# @param parameters [Hash{Symbol=>Object}]
|
|
104
|
+
# @param result [Hash{Symbol=>Object}]
|
|
105
|
+
# @param timestamp [Float]
|
|
106
|
+
# @param end_time [Float]
|
|
59
107
|
# @param token_usage [Stagehand::Models::SessionReplayResponse::Data::Page::Action::TokenUsage]
|
|
60
108
|
|
|
61
109
|
# @see Stagehand::Models::SessionReplayResponse::Data::Page::Action#token_usage
|
|
62
110
|
class TokenUsage < Stagehand::Internal::Type::BaseModel
|
|
63
|
-
# @!attribute
|
|
111
|
+
# @!attribute cost
|
|
64
112
|
#
|
|
65
113
|
# @return [Float, nil]
|
|
66
|
-
optional :
|
|
114
|
+
optional :cost, Float
|
|
67
115
|
|
|
68
116
|
# @!attribute input_tokens
|
|
69
117
|
#
|
|
@@ -75,21 +123,15 @@ module Stagehand
|
|
|
75
123
|
# @return [Float, nil]
|
|
76
124
|
optional :output_tokens, Float, api_name: :outputTokens
|
|
77
125
|
|
|
78
|
-
# @!attribute reasoning_tokens
|
|
79
|
-
#
|
|
80
|
-
# @return [Float, nil]
|
|
81
|
-
optional :reasoning_tokens, Float, api_name: :reasoningTokens
|
|
82
|
-
|
|
83
126
|
# @!attribute time_ms
|
|
84
127
|
#
|
|
85
128
|
# @return [Float, nil]
|
|
86
129
|
optional :time_ms, Float, api_name: :timeMs
|
|
87
130
|
|
|
88
|
-
# @!method initialize(
|
|
89
|
-
# @param
|
|
131
|
+
# @!method initialize(cost: nil, input_tokens: nil, output_tokens: nil, time_ms: nil)
|
|
132
|
+
# @param cost [Float]
|
|
90
133
|
# @param input_tokens [Float]
|
|
91
134
|
# @param output_tokens [Float]
|
|
92
|
-
# @param reasoning_tokens [Float]
|
|
93
135
|
# @param time_ms [Float]
|
|
94
136
|
end
|
|
95
137
|
end
|
data/lib/stagehand/version.rb
CHANGED
|
@@ -60,39 +60,35 @@ module Stagehand
|
|
|
60
60
|
|
|
61
61
|
sig do
|
|
62
62
|
returns(
|
|
63
|
-
T
|
|
64
|
-
T::Array[Stagehand::Models::SessionReplayResponse::Data::Page]
|
|
65
|
-
)
|
|
63
|
+
T::Array[Stagehand::Models::SessionReplayResponse::Data::Page]
|
|
66
64
|
)
|
|
67
65
|
end
|
|
68
|
-
|
|
66
|
+
attr_accessor :pages
|
|
69
67
|
|
|
70
|
-
sig
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
]
|
|
76
|
-
).void
|
|
77
|
-
end
|
|
78
|
-
attr_writer :pages
|
|
68
|
+
sig { returns(T.nilable(String)) }
|
|
69
|
+
attr_reader :client_language
|
|
70
|
+
|
|
71
|
+
sig { params(client_language: String).void }
|
|
72
|
+
attr_writer :client_language
|
|
79
73
|
|
|
80
74
|
sig do
|
|
81
75
|
params(
|
|
82
76
|
pages:
|
|
83
77
|
T::Array[
|
|
84
78
|
Stagehand::Models::SessionReplayResponse::Data::Page::OrHash
|
|
85
|
-
]
|
|
79
|
+
],
|
|
80
|
+
client_language: String
|
|
86
81
|
).returns(T.attached_class)
|
|
87
82
|
end
|
|
88
|
-
def self.new(pages: nil)
|
|
83
|
+
def self.new(pages:, client_language: nil)
|
|
89
84
|
end
|
|
90
85
|
|
|
91
86
|
sig do
|
|
92
87
|
override.returns(
|
|
93
88
|
{
|
|
94
89
|
pages:
|
|
95
|
-
T::Array[Stagehand::Models::SessionReplayResponse::Data::Page]
|
|
90
|
+
T::Array[Stagehand::Models::SessionReplayResponse::Data::Page],
|
|
91
|
+
client_language: String
|
|
96
92
|
}
|
|
97
93
|
)
|
|
98
94
|
end
|
|
@@ -110,34 +106,34 @@ module Stagehand
|
|
|
110
106
|
|
|
111
107
|
sig do
|
|
112
108
|
returns(
|
|
113
|
-
T
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
]
|
|
117
|
-
)
|
|
109
|
+
T::Array[
|
|
110
|
+
Stagehand::Models::SessionReplayResponse::Data::Page::Action
|
|
111
|
+
]
|
|
118
112
|
)
|
|
119
113
|
end
|
|
120
|
-
|
|
114
|
+
attr_accessor :actions
|
|
121
115
|
|
|
122
|
-
sig
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
attr_writer :actions
|
|
116
|
+
sig { returns(Float) }
|
|
117
|
+
attr_accessor :duration
|
|
118
|
+
|
|
119
|
+
sig { returns(Float) }
|
|
120
|
+
attr_accessor :timestamp
|
|
121
|
+
|
|
122
|
+
sig { returns(String) }
|
|
123
|
+
attr_accessor :url
|
|
131
124
|
|
|
132
125
|
sig do
|
|
133
126
|
params(
|
|
134
127
|
actions:
|
|
135
128
|
T::Array[
|
|
136
129
|
Stagehand::Models::SessionReplayResponse::Data::Page::Action::OrHash
|
|
137
|
-
]
|
|
130
|
+
],
|
|
131
|
+
duration: Float,
|
|
132
|
+
timestamp: Float,
|
|
133
|
+
url: String
|
|
138
134
|
).returns(T.attached_class)
|
|
139
135
|
end
|
|
140
|
-
def self.new(actions:
|
|
136
|
+
def self.new(actions:, duration:, timestamp:, url:)
|
|
141
137
|
end
|
|
142
138
|
|
|
143
139
|
sig do
|
|
@@ -146,7 +142,10 @@ module Stagehand
|
|
|
146
142
|
actions:
|
|
147
143
|
T::Array[
|
|
148
144
|
Stagehand::Models::SessionReplayResponse::Data::Page::Action
|
|
149
|
-
]
|
|
145
|
+
],
|
|
146
|
+
duration: Float,
|
|
147
|
+
timestamp: Float,
|
|
148
|
+
url: String
|
|
150
149
|
}
|
|
151
150
|
)
|
|
152
151
|
end
|
|
@@ -162,11 +161,23 @@ module Stagehand
|
|
|
162
161
|
)
|
|
163
162
|
end
|
|
164
163
|
|
|
165
|
-
sig { returns(
|
|
166
|
-
|
|
164
|
+
sig { returns(String) }
|
|
165
|
+
attr_accessor :method_
|
|
166
|
+
|
|
167
|
+
sig { returns(T::Hash[Symbol, T.anything]) }
|
|
168
|
+
attr_accessor :parameters
|
|
167
169
|
|
|
168
|
-
sig {
|
|
169
|
-
|
|
170
|
+
sig { returns(T::Hash[Symbol, T.anything]) }
|
|
171
|
+
attr_accessor :result
|
|
172
|
+
|
|
173
|
+
sig { returns(Float) }
|
|
174
|
+
attr_accessor :timestamp
|
|
175
|
+
|
|
176
|
+
sig { returns(T.nilable(Float)) }
|
|
177
|
+
attr_reader :end_time
|
|
178
|
+
|
|
179
|
+
sig { params(end_time: Float).void }
|
|
180
|
+
attr_writer :end_time
|
|
170
181
|
|
|
171
182
|
sig do
|
|
172
183
|
returns(
|
|
@@ -188,17 +199,32 @@ module Stagehand
|
|
|
188
199
|
sig do
|
|
189
200
|
params(
|
|
190
201
|
method_: String,
|
|
202
|
+
parameters: T::Hash[Symbol, T.anything],
|
|
203
|
+
result: T::Hash[Symbol, T.anything],
|
|
204
|
+
timestamp: Float,
|
|
205
|
+
end_time: Float,
|
|
191
206
|
token_usage:
|
|
192
207
|
Stagehand::Models::SessionReplayResponse::Data::Page::Action::TokenUsage::OrHash
|
|
193
208
|
).returns(T.attached_class)
|
|
194
209
|
end
|
|
195
|
-
def self.new(
|
|
210
|
+
def self.new(
|
|
211
|
+
method_:,
|
|
212
|
+
parameters:,
|
|
213
|
+
result:,
|
|
214
|
+
timestamp:,
|
|
215
|
+
end_time: nil,
|
|
216
|
+
token_usage: nil
|
|
217
|
+
)
|
|
196
218
|
end
|
|
197
219
|
|
|
198
220
|
sig do
|
|
199
221
|
override.returns(
|
|
200
222
|
{
|
|
201
223
|
method_: String,
|
|
224
|
+
parameters: T::Hash[Symbol, T.anything],
|
|
225
|
+
result: T::Hash[Symbol, T.anything],
|
|
226
|
+
timestamp: Float,
|
|
227
|
+
end_time: Float,
|
|
202
228
|
token_usage:
|
|
203
229
|
Stagehand::Models::SessionReplayResponse::Data::Page::Action::TokenUsage
|
|
204
230
|
}
|
|
@@ -217,10 +243,10 @@ module Stagehand
|
|
|
217
243
|
end
|
|
218
244
|
|
|
219
245
|
sig { returns(T.nilable(Float)) }
|
|
220
|
-
attr_reader :
|
|
246
|
+
attr_reader :cost
|
|
221
247
|
|
|
222
|
-
sig { params(
|
|
223
|
-
attr_writer :
|
|
248
|
+
sig { params(cost: Float).void }
|
|
249
|
+
attr_writer :cost
|
|
224
250
|
|
|
225
251
|
sig { returns(T.nilable(Float)) }
|
|
226
252
|
attr_reader :input_tokens
|
|
@@ -234,12 +260,6 @@ module Stagehand
|
|
|
234
260
|
sig { params(output_tokens: Float).void }
|
|
235
261
|
attr_writer :output_tokens
|
|
236
262
|
|
|
237
|
-
sig { returns(T.nilable(Float)) }
|
|
238
|
-
attr_reader :reasoning_tokens
|
|
239
|
-
|
|
240
|
-
sig { params(reasoning_tokens: Float).void }
|
|
241
|
-
attr_writer :reasoning_tokens
|
|
242
|
-
|
|
243
263
|
sig { returns(T.nilable(Float)) }
|
|
244
264
|
attr_reader :time_ms
|
|
245
265
|
|
|
@@ -248,18 +268,16 @@ module Stagehand
|
|
|
248
268
|
|
|
249
269
|
sig do
|
|
250
270
|
params(
|
|
251
|
-
|
|
271
|
+
cost: Float,
|
|
252
272
|
input_tokens: Float,
|
|
253
273
|
output_tokens: Float,
|
|
254
|
-
reasoning_tokens: Float,
|
|
255
274
|
time_ms: Float
|
|
256
275
|
).returns(T.attached_class)
|
|
257
276
|
end
|
|
258
277
|
def self.new(
|
|
259
|
-
|
|
278
|
+
cost: nil,
|
|
260
279
|
input_tokens: nil,
|
|
261
280
|
output_tokens: nil,
|
|
262
|
-
reasoning_tokens: nil,
|
|
263
281
|
time_ms: nil
|
|
264
282
|
)
|
|
265
283
|
end
|
|
@@ -267,10 +285,9 @@ module Stagehand
|
|
|
267
285
|
sig do
|
|
268
286
|
override.returns(
|
|
269
287
|
{
|
|
270
|
-
|
|
288
|
+
cost: Float,
|
|
271
289
|
input_tokens: Float,
|
|
272
290
|
output_tokens: Float,
|
|
273
|
-
reasoning_tokens: Float,
|
|
274
291
|
time_ms: Float
|
|
275
292
|
}
|
|
276
293
|
)
|
|
@@ -19,53 +19,81 @@ module Stagehand
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
type data =
|
|
22
|
-
{
|
|
22
|
+
{
|
|
23
|
+
pages: ::Array[Stagehand::Models::SessionReplayResponse::Data::Page],
|
|
24
|
+
client_language: String
|
|
25
|
+
}
|
|
23
26
|
|
|
24
27
|
class Data < Stagehand::Internal::Type::BaseModel
|
|
25
|
-
|
|
28
|
+
attr_accessor pages: ::Array[Stagehand::Models::SessionReplayResponse::Data::Page]
|
|
29
|
+
|
|
30
|
+
attr_reader client_language: String?
|
|
26
31
|
|
|
27
|
-
def
|
|
28
|
-
::Array[Stagehand::Models::SessionReplayResponse::Data::Page]
|
|
29
|
-
) -> ::Array[Stagehand::Models::SessionReplayResponse::Data::Page]
|
|
32
|
+
def client_language=: (String) -> String
|
|
30
33
|
|
|
31
34
|
def initialize: (
|
|
32
|
-
|
|
35
|
+
pages: ::Array[Stagehand::Models::SessionReplayResponse::Data::Page],
|
|
36
|
+
?client_language: String
|
|
33
37
|
) -> void
|
|
34
38
|
|
|
35
39
|
def to_hash: -> {
|
|
36
|
-
pages: ::Array[Stagehand::Models::SessionReplayResponse::Data::Page]
|
|
40
|
+
pages: ::Array[Stagehand::Models::SessionReplayResponse::Data::Page],
|
|
41
|
+
client_language: String
|
|
37
42
|
}
|
|
38
43
|
|
|
39
44
|
type page =
|
|
40
45
|
{
|
|
41
|
-
actions: ::Array[Stagehand::Models::SessionReplayResponse::Data::Page::Action]
|
|
46
|
+
actions: ::Array[Stagehand::Models::SessionReplayResponse::Data::Page::Action],
|
|
47
|
+
duration: Float,
|
|
48
|
+
timestamp: Float,
|
|
49
|
+
url: String
|
|
42
50
|
}
|
|
43
51
|
|
|
44
52
|
class Page < Stagehand::Internal::Type::BaseModel
|
|
45
|
-
|
|
53
|
+
attr_accessor actions: ::Array[Stagehand::Models::SessionReplayResponse::Data::Page::Action]
|
|
54
|
+
|
|
55
|
+
attr_accessor duration: Float
|
|
46
56
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
attr_accessor timestamp: Float
|
|
58
|
+
|
|
59
|
+
attr_accessor url: String
|
|
50
60
|
|
|
51
61
|
def initialize: (
|
|
52
|
-
|
|
62
|
+
actions: ::Array[Stagehand::Models::SessionReplayResponse::Data::Page::Action],
|
|
63
|
+
duration: Float,
|
|
64
|
+
timestamp: Float,
|
|
65
|
+
url: String
|
|
53
66
|
) -> void
|
|
54
67
|
|
|
55
68
|
def to_hash: -> {
|
|
56
|
-
actions: ::Array[Stagehand::Models::SessionReplayResponse::Data::Page::Action]
|
|
69
|
+
actions: ::Array[Stagehand::Models::SessionReplayResponse::Data::Page::Action],
|
|
70
|
+
duration: Float,
|
|
71
|
+
timestamp: Float,
|
|
72
|
+
url: String
|
|
57
73
|
}
|
|
58
74
|
|
|
59
75
|
type action =
|
|
60
76
|
{
|
|
61
77
|
method_: String,
|
|
78
|
+
parameters: ::Hash[Symbol, top],
|
|
79
|
+
result: ::Hash[Symbol, top],
|
|
80
|
+
timestamp: Float,
|
|
81
|
+
end_time: Float,
|
|
62
82
|
token_usage: Stagehand::Models::SessionReplayResponse::Data::Page::Action::TokenUsage
|
|
63
83
|
}
|
|
64
84
|
|
|
65
85
|
class Action < Stagehand::Internal::Type::BaseModel
|
|
66
|
-
|
|
86
|
+
attr_accessor method_: String
|
|
87
|
+
|
|
88
|
+
attr_accessor parameters: ::Hash[Symbol, top]
|
|
89
|
+
|
|
90
|
+
attr_accessor result: ::Hash[Symbol, top]
|
|
67
91
|
|
|
68
|
-
|
|
92
|
+
attr_accessor timestamp: Float
|
|
93
|
+
|
|
94
|
+
attr_reader end_time: Float?
|
|
95
|
+
|
|
96
|
+
def end_time=: (Float) -> Float
|
|
69
97
|
|
|
70
98
|
attr_reader token_usage: Stagehand::Models::SessionReplayResponse::Data::Page::Action::TokenUsage?
|
|
71
99
|
|
|
@@ -74,28 +102,35 @@ module Stagehand
|
|
|
74
102
|
) -> Stagehand::Models::SessionReplayResponse::Data::Page::Action::TokenUsage
|
|
75
103
|
|
|
76
104
|
def initialize: (
|
|
77
|
-
|
|
105
|
+
method_: String,
|
|
106
|
+
parameters: ::Hash[Symbol, top],
|
|
107
|
+
result: ::Hash[Symbol, top],
|
|
108
|
+
timestamp: Float,
|
|
109
|
+
?end_time: Float,
|
|
78
110
|
?token_usage: Stagehand::Models::SessionReplayResponse::Data::Page::Action::TokenUsage
|
|
79
111
|
) -> void
|
|
80
112
|
|
|
81
113
|
def to_hash: -> {
|
|
82
114
|
method_: String,
|
|
115
|
+
parameters: ::Hash[Symbol, top],
|
|
116
|
+
result: ::Hash[Symbol, top],
|
|
117
|
+
timestamp: Float,
|
|
118
|
+
end_time: Float,
|
|
83
119
|
token_usage: Stagehand::Models::SessionReplayResponse::Data::Page::Action::TokenUsage
|
|
84
120
|
}
|
|
85
121
|
|
|
86
122
|
type token_usage =
|
|
87
123
|
{
|
|
88
|
-
|
|
124
|
+
cost: Float,
|
|
89
125
|
input_tokens: Float,
|
|
90
126
|
output_tokens: Float,
|
|
91
|
-
reasoning_tokens: Float,
|
|
92
127
|
time_ms: Float
|
|
93
128
|
}
|
|
94
129
|
|
|
95
130
|
class TokenUsage < Stagehand::Internal::Type::BaseModel
|
|
96
|
-
attr_reader
|
|
131
|
+
attr_reader cost: Float?
|
|
97
132
|
|
|
98
|
-
def
|
|
133
|
+
def cost=: (Float) -> Float
|
|
99
134
|
|
|
100
135
|
attr_reader input_tokens: Float?
|
|
101
136
|
|
|
@@ -105,27 +140,21 @@ module Stagehand
|
|
|
105
140
|
|
|
106
141
|
def output_tokens=: (Float) -> Float
|
|
107
142
|
|
|
108
|
-
attr_reader reasoning_tokens: Float?
|
|
109
|
-
|
|
110
|
-
def reasoning_tokens=: (Float) -> Float
|
|
111
|
-
|
|
112
143
|
attr_reader time_ms: Float?
|
|
113
144
|
|
|
114
145
|
def time_ms=: (Float) -> Float
|
|
115
146
|
|
|
116
147
|
def initialize: (
|
|
117
|
-
?
|
|
148
|
+
?cost: Float,
|
|
118
149
|
?input_tokens: Float,
|
|
119
150
|
?output_tokens: Float,
|
|
120
|
-
?reasoning_tokens: Float,
|
|
121
151
|
?time_ms: Float
|
|
122
152
|
) -> void
|
|
123
153
|
|
|
124
154
|
def to_hash: -> {
|
|
125
|
-
|
|
155
|
+
cost: Float,
|
|
126
156
|
input_tokens: Float,
|
|
127
157
|
output_tokens: Float,
|
|
128
|
-
reasoning_tokens: Float,
|
|
129
158
|
time_ms: Float
|
|
130
159
|
}
|
|
131
160
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: stagehand
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stagehand
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-02-
|
|
11
|
+
date: 2026-02-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: cgi
|