stagehand 3.18.0 → 3.20.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 +45 -0
- data/README.md +5 -6
- data/lib/stagehand/client.rb +25 -13
- data/lib/stagehand/internal/util.rb +22 -7
- data/lib/stagehand/local.rb +3 -12
- data/lib/stagehand/models/session_execute_params.rb +56 -1
- data/lib/stagehand/models/session_extract_params.rb +9 -1
- data/lib/stagehand/models/session_start_params.rb +56 -2
- data/lib/stagehand/resources/sessions.rb +16 -4
- data/lib/stagehand/version.rb +1 -1
- data/rbi/stagehand/client.rbi +6 -6
- data/rbi/stagehand/internal/util.rbi +8 -0
- data/rbi/stagehand/models/session_execute_params.rbi +144 -3
- data/rbi/stagehand/models/session_extract_params.rbi +11 -0
- data/rbi/stagehand/models/session_start_params.rbi +102 -0
- data/sig/stagehand/internal/util.rbs +4 -0
- data/sig/stagehand/models/session_execute_params.rbs +56 -3
- data/sig/stagehand/models/session_extract_params.rbs +7 -0
- data/sig/stagehand/models/session_start_params.rbs +44 -0
- 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: d63d07d6d72284d6745a7f938ec12a7153c43a8cc9baba9e6bbf2559fd77b1e3
|
|
4
|
+
data.tar.gz: 8aa6950f119f872fddbb4d047e3ddb17253363c016c4be81bd573cd6a53b7bb0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f8281b0509afbe153829b60b77e259c98339f348654ed58e216a8d43003cf99aadba760de930518c62e1350ae37cb31fcab4a2e5fe6b5dbbfad07e94fc29ce62
|
|
7
|
+
data.tar.gz: 295b43fd779e909fd5c8b78e42b6a5b6b1f45686a47392136a08e4860c16e7382a203caaa9b8806e341a96dc4ca2789ee5a92e1c3606169516848ac577e2d31d
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.20.0 (2026-05-06)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v3.19.3...v3.20.0](https://github.com/browserbase/stagehand-ruby/compare/v3.19.3...v3.20.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* [feat]: add `ignoreSelectors` to `extract()` ([db24a9a](https://github.com/browserbase/stagehand-ruby/commit/db24a9ab45dc464d2ad88f9b50d39952c4c76801))
|
|
10
|
+
* [STG-1798] feat: support Browserbase verified sessions ([9647eb3](https://github.com/browserbase/stagehand-ruby/commit/9647eb3a4df86cc9d7aedb2f0a9ddd0babd39565))
|
|
11
|
+
* [STG-1808] Deprecate Browserbase project ID ([7af1c21](https://github.com/browserbase/stagehand-ruby/commit/7af1c21a07e7163ffb0b86f6c199989b750e0365))
|
|
12
|
+
* Bedrock auth passthrough ([5cb6ecb](https://github.com/browserbase/stagehand-ruby/commit/5cb6ecbe621e894dc6c5aec379fdca1183eec4fc))
|
|
13
|
+
* remove experimental requirement on agent variables ([#2079](https://github.com/browserbase/stagehand-ruby/issues/2079)) ([6f106d7](https://github.com/browserbase/stagehand-ruby/commit/6f106d74feb1b3f036433ec67dda5e4c395f434e))
|
|
14
|
+
* Revert "[STG-1573] Add providerOptions for extensible model auth ([#1822](https://github.com/browserbase/stagehand-ruby/issues/1822))" ([0c83a09](https://github.com/browserbase/stagehand-ruby/commit/0c83a0978116f8fc11a4edf78586f3d61b8af5e8))
|
|
15
|
+
* support setting headers via env ([5515959](https://github.com/browserbase/stagehand-ruby/commit/5515959505685e62f9324aebf470a295dd6d8292))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* avoid gzip buffering during streaming ([23c3eef](https://github.com/browserbase/stagehand-ruby/commit/23c3eef17497edbf3ec03049d12c548607112c8d))
|
|
21
|
+
* multipart encoding for file arrays ([149b303](https://github.com/browserbase/stagehand-ruby/commit/149b303eb54f4c9af037a5e073a2d6c92d959b44))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Chores
|
|
25
|
+
|
|
26
|
+
* **internal:** more robust bootstrap script ([69c050a](https://github.com/browserbase/stagehand-ruby/commit/69c050a467b5fcab904331bd30bd18d46cee8cae))
|
|
27
|
+
|
|
28
|
+
## 3.19.3 (2026-04-03)
|
|
29
|
+
|
|
30
|
+
Full Changelog: [v3.18.0...v3.19.3](https://github.com/browserbase/stagehand-ruby/compare/v3.18.0...v3.19.3)
|
|
31
|
+
|
|
32
|
+
### Features
|
|
33
|
+
|
|
34
|
+
* Replace default model used in server-v3 api spec examples ([0460af2](https://github.com/browserbase/stagehand-ruby/commit/0460af273ab6ba521a01847fe943032b619f7922))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Bug Fixes
|
|
38
|
+
|
|
39
|
+
* align path encoding with RFC 3986 section 3.3 ([4f07e2e](https://github.com/browserbase/stagehand-ruby/commit/4f07e2eb4439a53ed1d830f0471b563656f19832))
|
|
40
|
+
* **internal:** correct multipart form field name encoding ([2478726](https://github.com/browserbase/stagehand-ruby/commit/247872691f0c955d19b06cdfac5a4feb13477c1f))
|
|
41
|
+
* variable name typo ([41c9b71](https://github.com/browserbase/stagehand-ruby/commit/41c9b719de177dc28c3f5b167bb96a136336866d))
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
### Chores
|
|
45
|
+
|
|
46
|
+
* **ci:** support opting out of skipping builds on metadata-only commits ([cb20c91](https://github.com/browserbase/stagehand-ruby/commit/cb20c91371c9be0282616f9137e51a2414b8a969))
|
|
47
|
+
|
|
3
48
|
## 3.18.0 (2026-03-25)
|
|
4
49
|
|
|
5
50
|
Full Changelog: [v3.7.1...v3.18.0](https://github.com/browserbase/stagehand-ruby/compare/v3.7.1...v3.18.0)
|
data/README.md
CHANGED
|
@@ -90,7 +90,6 @@ require "playwright"
|
|
|
90
90
|
|
|
91
91
|
client = Stagehand::Client.new(
|
|
92
92
|
browserbase_api_key: ENV["BROWSERBASE_API_KEY"],
|
|
93
|
-
browserbase_project_id: ENV["BROWSERBASE_PROJECT_ID"],
|
|
94
93
|
model_api_key: ENV["MODEL_API_KEY"],
|
|
95
94
|
server: "remote"
|
|
96
95
|
)
|
|
@@ -162,10 +161,10 @@ client.sessions.end_(session_id)
|
|
|
162
161
|
|
|
163
162
|
Set your environment variables (from `examples/.env.example`):
|
|
164
163
|
|
|
165
|
-
- `STAGEHAND_API_URL`
|
|
166
164
|
- `MODEL_API_KEY`
|
|
167
165
|
- `BROWSERBASE_API_KEY`
|
|
168
|
-
|
|
166
|
+
|
|
167
|
+
`STAGEHAND_API_URL` is optional and defaults to the hosted Stagehand API. `STAGEHAND_BASE_URL` remains supported as a deprecated fallback when `STAGEHAND_API_URL` is unset.
|
|
169
168
|
|
|
170
169
|
```bash
|
|
171
170
|
cp examples/.env.example examples/.env
|
|
@@ -213,7 +212,7 @@ When the library is unable to connect to the API, or if the API returns a non-su
|
|
|
213
212
|
|
|
214
213
|
```ruby
|
|
215
214
|
begin
|
|
216
|
-
session = stagehand.sessions.start(model_name: "
|
|
215
|
+
session = stagehand.sessions.start(model_name: "openai/gpt-5.4-mini")
|
|
217
216
|
rescue Stagehand::Errors::APIConnectionError => e
|
|
218
217
|
puts("The server could not be reached")
|
|
219
218
|
puts(e.cause) # an underlying Exception, likely raised within `net/http`
|
|
@@ -256,7 +255,7 @@ stagehand = Stagehand::Client.new(
|
|
|
256
255
|
)
|
|
257
256
|
|
|
258
257
|
# Or, configure per-request:
|
|
259
|
-
stagehand.sessions.start(model_name: "
|
|
258
|
+
stagehand.sessions.start(model_name: "openai/gpt-5.4-mini", request_options: {max_retries: 5})
|
|
260
259
|
```
|
|
261
260
|
|
|
262
261
|
### Timeouts
|
|
@@ -270,7 +269,7 @@ stagehand = Stagehand::Client.new(
|
|
|
270
269
|
)
|
|
271
270
|
|
|
272
271
|
# Or, configure per-request:
|
|
273
|
-
stagehand.sessions.start(model_name: "
|
|
272
|
+
stagehand.sessions.start(model_name: "openai/gpt-5.4-mini", request_options: {timeout: 5})
|
|
274
273
|
```
|
|
275
274
|
|
|
276
275
|
On timeout, `Stagehand::Errors::APITimeoutError` is raised.
|
data/lib/stagehand/client.rb
CHANGED
|
@@ -19,7 +19,8 @@ module Stagehand
|
|
|
19
19
|
# @return [String]
|
|
20
20
|
attr_reader :browserbase_api_key
|
|
21
21
|
|
|
22
|
-
#
|
|
22
|
+
# Deprecated. Browserbase API keys are now project-scoped, so this value is accepted for
|
|
23
|
+
# backwards compatibility and ignored.
|
|
23
24
|
# @return [String]
|
|
24
25
|
attr_reader :browserbase_project_id
|
|
25
26
|
|
|
@@ -34,7 +35,7 @@ module Stagehand
|
|
|
34
35
|
#
|
|
35
36
|
# @return [Hash{String=>String}]
|
|
36
37
|
private def auth_headers
|
|
37
|
-
{**bb_api_key_auth, **
|
|
38
|
+
{**bb_api_key_auth, **llm_model_api_key_auth}
|
|
38
39
|
end
|
|
39
40
|
|
|
40
41
|
# @api private
|
|
@@ -48,7 +49,7 @@ module Stagehand
|
|
|
48
49
|
#
|
|
49
50
|
# @return [Hash{String=>String}]
|
|
50
51
|
private def bb_project_id_auth
|
|
51
|
-
{
|
|
52
|
+
{}
|
|
52
53
|
end
|
|
53
54
|
|
|
54
55
|
# @api private
|
|
@@ -63,8 +64,8 @@ module Stagehand
|
|
|
63
64
|
# @param browserbase_api_key [String, nil] Your [Browserbase API Key](https://www.browserbase.com/settings) Defaults to
|
|
64
65
|
# `ENV["BROWSERBASE_API_KEY"]`
|
|
65
66
|
#
|
|
66
|
-
# @param browserbase_project_id [String, nil]
|
|
67
|
-
#
|
|
67
|
+
# @param browserbase_project_id [String, nil] Deprecated. Browserbase API keys are now project-scoped, so
|
|
68
|
+
# this value is accepted for backwards compatibility and ignored.
|
|
68
69
|
#
|
|
69
70
|
# @param model_api_key [String, nil] Your LLM provider API key (e.g. OPENAI_API_KEY, ANTHROPIC_API_KEY, etc.)
|
|
70
71
|
# Defaults to `ENV["MODEL_API_KEY"]`
|
|
@@ -72,7 +73,8 @@ module Stagehand
|
|
|
72
73
|
# @param server [String] Server mode to use ("remote" or "local"). Defaults to "remote"
|
|
73
74
|
#
|
|
74
75
|
# @param base_url [String, nil] Override the default base URL for the API, e.g.,
|
|
75
|
-
# `"https://api.example.com/v2/"`. Defaults to `ENV["
|
|
76
|
+
# `"https://api.example.com/v2/"`. Defaults to `ENV["STAGEHAND_API_URL"]`,
|
|
77
|
+
# then `ENV["STAGEHAND_BASE_URL"]`
|
|
76
78
|
#
|
|
77
79
|
# @param max_retries [Integer] Max number of retries to attempt after a failed retryable request.
|
|
78
80
|
#
|
|
@@ -83,10 +85,10 @@ module Stagehand
|
|
|
83
85
|
# @param max_retry_delay [Float]
|
|
84
86
|
def initialize(
|
|
85
87
|
browserbase_api_key: ENV["BROWSERBASE_API_KEY"],
|
|
86
|
-
browserbase_project_id:
|
|
88
|
+
browserbase_project_id: nil,
|
|
87
89
|
model_api_key: ENV["MODEL_API_KEY"],
|
|
88
90
|
server: "remote",
|
|
89
|
-
base_url: ENV["STAGEHAND_BASE_URL"],
|
|
91
|
+
base_url: ENV["STAGEHAND_API_URL"] || ENV["STAGEHAND_BASE_URL"],
|
|
90
92
|
max_retries: self.class::DEFAULT_MAX_RETRIES,
|
|
91
93
|
timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS,
|
|
92
94
|
initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY,
|
|
@@ -99,15 +101,24 @@ module Stagehand
|
|
|
99
101
|
raise ArgumentError,
|
|
100
102
|
"browserbase_api_key is required, and can be set via environ: \"BROWSERBASE_API_KEY\""
|
|
101
103
|
end
|
|
102
|
-
if browserbase_project_id.nil?
|
|
103
|
-
raise ArgumentError,
|
|
104
|
-
"browserbase_project_id is required, and can be set via environ: \"BROWSERBASE_PROJECT_ID\""
|
|
105
|
-
end
|
|
106
104
|
if model_api_key.nil?
|
|
107
105
|
raise ArgumentError,
|
|
108
106
|
"model_api_key is required, and can be set via environ: \"MODEL_API_KEY\""
|
|
109
107
|
end
|
|
110
108
|
|
|
109
|
+
headers = {}
|
|
110
|
+
custom_headers_env = ENV["STAGEHAND_CUSTOM_HEADERS"]
|
|
111
|
+
unless custom_headers_env.nil?
|
|
112
|
+
parsed = {}
|
|
113
|
+
custom_headers_env.split("\n").each do |line|
|
|
114
|
+
colon = line.index(":")
|
|
115
|
+
unless colon.nil?
|
|
116
|
+
parsed[line[0...colon].strip] = line[(colon + 1)..].strip
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
headers = parsed.merge(headers)
|
|
120
|
+
end
|
|
121
|
+
|
|
111
122
|
@browserbase_api_key = browserbase_api_key.to_s
|
|
112
123
|
@browserbase_project_id = browserbase_project_id.to_s
|
|
113
124
|
@model_api_key = model_api_key.to_s
|
|
@@ -117,7 +128,8 @@ module Stagehand
|
|
|
117
128
|
timeout: timeout,
|
|
118
129
|
max_retries: max_retries,
|
|
119
130
|
initial_retry_delay: initial_retry_delay,
|
|
120
|
-
max_retry_delay: max_retry_delay
|
|
131
|
+
max_retry_delay: max_retry_delay,
|
|
132
|
+
headers: headers
|
|
121
133
|
)
|
|
122
134
|
|
|
123
135
|
@sessions = Stagehand::Resources::Sessions.new(client: self)
|
|
@@ -157,7 +157,7 @@ module Stagehand
|
|
|
157
157
|
in Hash | nil => coerced
|
|
158
158
|
coerced
|
|
159
159
|
else
|
|
160
|
-
message = "Expected a #{Hash} or #{Stagehand::Internal::Type::BaseModel}, got #{
|
|
160
|
+
message = "Expected a #{Hash} or #{Stagehand::Internal::Type::BaseModel}, got #{input.inspect}"
|
|
161
161
|
raise ArgumentError.new(message)
|
|
162
162
|
end
|
|
163
163
|
end
|
|
@@ -237,6 +237,11 @@ module Stagehand
|
|
|
237
237
|
end
|
|
238
238
|
end
|
|
239
239
|
|
|
240
|
+
# @type [Regexp]
|
|
241
|
+
#
|
|
242
|
+
# https://www.rfc-editor.org/rfc/rfc3986.html#section-3.3
|
|
243
|
+
RFC_3986_NOT_PCHARS = /[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/
|
|
244
|
+
|
|
240
245
|
class << self
|
|
241
246
|
# @api private
|
|
242
247
|
#
|
|
@@ -247,6 +252,15 @@ module Stagehand
|
|
|
247
252
|
"#{uri.scheme}://#{uri.host}#{":#{uri.port}" unless uri.port == uri.default_port}"
|
|
248
253
|
end
|
|
249
254
|
|
|
255
|
+
# @api private
|
|
256
|
+
#
|
|
257
|
+
# @param path [String, Integer]
|
|
258
|
+
#
|
|
259
|
+
# @return [String]
|
|
260
|
+
def encode_path(path)
|
|
261
|
+
path.to_s.gsub(Stagehand::Internal::Util::RFC_3986_NOT_PCHARS) { ERB::Util.url_encode(_1) }
|
|
262
|
+
end
|
|
263
|
+
|
|
250
264
|
# @api private
|
|
251
265
|
#
|
|
252
266
|
# @param path [String, Array<String>]
|
|
@@ -259,7 +273,7 @@ module Stagehand
|
|
|
259
273
|
in []
|
|
260
274
|
""
|
|
261
275
|
in [String => p, *interpolations]
|
|
262
|
-
encoded = interpolations.map {
|
|
276
|
+
encoded = interpolations.map { encode_path(_1) }
|
|
263
277
|
format(p, *encoded)
|
|
264
278
|
end
|
|
265
279
|
end
|
|
@@ -571,16 +585,15 @@ module Stagehand
|
|
|
571
585
|
y << "Content-Disposition: form-data"
|
|
572
586
|
|
|
573
587
|
unless key.nil?
|
|
574
|
-
|
|
575
|
-
y << "; name=\"#{name}\""
|
|
588
|
+
y << "; name=\"#{key}\""
|
|
576
589
|
end
|
|
577
590
|
|
|
578
591
|
case val
|
|
579
592
|
in Stagehand::FilePart unless val.filename.nil?
|
|
580
|
-
filename =
|
|
593
|
+
filename = encode_path(val.filename)
|
|
581
594
|
y << "; filename=\"#{filename}\""
|
|
582
595
|
in Pathname | IO
|
|
583
|
-
filename =
|
|
596
|
+
filename = encode_path(::File.basename(val.to_path))
|
|
584
597
|
y << "; filename=\"#{filename}\""
|
|
585
598
|
else
|
|
586
599
|
end
|
|
@@ -597,6 +610,7 @@ module Stagehand
|
|
|
597
610
|
#
|
|
598
611
|
# @return [Array(String, Enumerable<String>)]
|
|
599
612
|
private def encode_multipart_streaming(body)
|
|
613
|
+
# rubocop:disable Style/CaseEquality
|
|
600
614
|
# RFC 1521 Section 7.2.1 says we should have 70 char maximum for boundary length
|
|
601
615
|
boundary = SecureRandom.urlsafe_base64(46)
|
|
602
616
|
|
|
@@ -606,7 +620,7 @@ module Stagehand
|
|
|
606
620
|
in Hash
|
|
607
621
|
body.each do |key, val|
|
|
608
622
|
case val
|
|
609
|
-
in Array if val.all? { primitive?(_1) }
|
|
623
|
+
in Array if val.all? { primitive?(_1) || Stagehand::Internal::Type::FileInput === _1 }
|
|
610
624
|
val.each do |v|
|
|
611
625
|
write_multipart_chunk(y, boundary: boundary, key: key, val: v, closing: closing)
|
|
612
626
|
end
|
|
@@ -622,6 +636,7 @@ module Stagehand
|
|
|
622
636
|
|
|
623
637
|
fused_io = fused_enum(strio) { closing.each(&:call) }
|
|
624
638
|
[boundary, fused_io]
|
|
639
|
+
# rubocop:enable Style/CaseEquality
|
|
625
640
|
end
|
|
626
641
|
|
|
627
642
|
# @api private
|
data/lib/stagehand/local.rb
CHANGED
|
@@ -50,7 +50,6 @@ module Stagehand
|
|
|
50
50
|
|
|
51
51
|
missing = []
|
|
52
52
|
missing << "browserbase_api_key" if client.browserbase_api_key.to_s.empty?
|
|
53
|
-
missing << "browserbase_project_id" if client.browserbase_project_id.to_s.empty?
|
|
54
53
|
return if missing.empty?
|
|
55
54
|
|
|
56
55
|
message =
|
|
@@ -213,10 +212,9 @@ module Stagehand
|
|
|
213
212
|
end
|
|
214
213
|
|
|
215
214
|
class ServerManager
|
|
216
|
-
def initialize(model_api_key:, browserbase_api_key
|
|
215
|
+
def initialize(model_api_key:, browserbase_api_key:)
|
|
217
216
|
@model_api_key = model_api_key
|
|
218
217
|
@browserbase_api_key = browserbase_api_key
|
|
219
|
-
@browserbase_project_id = browserbase_project_id
|
|
220
218
|
@host = DEFAULT_HOST
|
|
221
219
|
@port = 0
|
|
222
220
|
@mutex = Mutex.new
|
|
@@ -335,9 +333,6 @@ module Stagehand
|
|
|
335
333
|
if @browserbase_api_key.to_s != ""
|
|
336
334
|
env["BROWSERBASE_API_KEY"] = @browserbase_api_key
|
|
337
335
|
end
|
|
338
|
-
if @browserbase_project_id.to_s != ""
|
|
339
|
-
env["BROWSERBASE_PROJECT_ID"] = @browserbase_project_id
|
|
340
|
-
end
|
|
341
336
|
env
|
|
342
337
|
end
|
|
343
338
|
|
|
@@ -376,8 +371,6 @@ module Stagehand
|
|
|
376
371
|
kwargs[:base_url] = base_url.nil? ? "http://#{DEFAULT_HOST}" : base_url
|
|
377
372
|
kwargs[:browserbase_api_key] =
|
|
378
373
|
kwargs[:browserbase_api_key] || ENV["BROWSERBASE_API_KEY"] || ""
|
|
379
|
-
kwargs[:browserbase_project_id] =
|
|
380
|
-
kwargs[:browserbase_project_id] || ENV["BROWSERBASE_PROJECT_ID"] || ""
|
|
381
374
|
end
|
|
382
375
|
|
|
383
376
|
super(**kwargs)
|
|
@@ -386,8 +379,7 @@ module Stagehand
|
|
|
386
379
|
|
|
387
380
|
@local_server_manager = Stagehand::Local::ServerManager.new(
|
|
388
381
|
model_api_key: @model_api_key,
|
|
389
|
-
browserbase_api_key: @browserbase_api_key
|
|
390
|
-
browserbase_project_id: @browserbase_project_id
|
|
382
|
+
browserbase_api_key: @browserbase_api_key
|
|
391
383
|
)
|
|
392
384
|
end
|
|
393
385
|
|
|
@@ -421,8 +413,7 @@ module Stagehand
|
|
|
421
413
|
end
|
|
422
414
|
|
|
423
415
|
def bb_project_id_auth
|
|
424
|
-
|
|
425
|
-
super
|
|
416
|
+
{}
|
|
426
417
|
end
|
|
427
418
|
end
|
|
428
419
|
|
|
@@ -210,7 +210,14 @@ module Stagehand
|
|
|
210
210
|
# @return [Boolean, nil]
|
|
211
211
|
optional :use_search, Stagehand::Internal::Type::Boolean, api_name: :useSearch
|
|
212
212
|
|
|
213
|
-
# @!
|
|
213
|
+
# @!attribute variables
|
|
214
|
+
# Variables available to the agent via %variableName% syntax in supported tools
|
|
215
|
+
#
|
|
216
|
+
# @return [Hash{Symbol=>String, Float, Boolean, Stagehand::Models::SessionExecuteParams::ExecuteOptions::Variable::UnionMember3}, nil]
|
|
217
|
+
optional :variables,
|
|
218
|
+
-> { Stagehand::Internal::Type::HashOf[union: Stagehand::SessionExecuteParams::ExecuteOptions::Variable] }
|
|
219
|
+
|
|
220
|
+
# @!method initialize(instruction:, highlight_cursor: nil, max_steps: nil, tool_timeout: nil, use_search: nil, variables: nil)
|
|
214
221
|
# @param instruction [String] Natural language instruction for the agent
|
|
215
222
|
#
|
|
216
223
|
# @param highlight_cursor [Boolean] Whether to visually highlight the cursor during execution
|
|
@@ -220,6 +227,54 @@ module Stagehand
|
|
|
220
227
|
# @param tool_timeout [Float] Timeout in milliseconds for each agent tool call
|
|
221
228
|
#
|
|
222
229
|
# @param use_search [Boolean] Whether to enable the web search tool powered by Browserbase Search API
|
|
230
|
+
#
|
|
231
|
+
# @param variables [Hash{Symbol=>String, Float, Boolean, Stagehand::Models::SessionExecuteParams::ExecuteOptions::Variable::UnionMember3}] Variables available to the agent via %variableName% syntax in supported tools
|
|
232
|
+
|
|
233
|
+
module Variable
|
|
234
|
+
extend Stagehand::Internal::Type::Union
|
|
235
|
+
|
|
236
|
+
variant String
|
|
237
|
+
|
|
238
|
+
variant Float
|
|
239
|
+
|
|
240
|
+
variant Stagehand::Internal::Type::Boolean
|
|
241
|
+
|
|
242
|
+
variant -> { Stagehand::SessionExecuteParams::ExecuteOptions::Variable::UnionMember3 }
|
|
243
|
+
|
|
244
|
+
class UnionMember3 < Stagehand::Internal::Type::BaseModel
|
|
245
|
+
# @!attribute value
|
|
246
|
+
#
|
|
247
|
+
# @return [String, Float, Boolean]
|
|
248
|
+
required :value,
|
|
249
|
+
union: -> { Stagehand::SessionExecuteParams::ExecuteOptions::Variable::UnionMember3::Value }
|
|
250
|
+
|
|
251
|
+
# @!attribute description
|
|
252
|
+
#
|
|
253
|
+
# @return [String, nil]
|
|
254
|
+
optional :description, String
|
|
255
|
+
|
|
256
|
+
# @!method initialize(value:, description: nil)
|
|
257
|
+
# @param value [String, Float, Boolean]
|
|
258
|
+
# @param description [String]
|
|
259
|
+
|
|
260
|
+
# @see Stagehand::Models::SessionExecuteParams::ExecuteOptions::Variable::UnionMember3#value
|
|
261
|
+
module Value
|
|
262
|
+
extend Stagehand::Internal::Type::Union
|
|
263
|
+
|
|
264
|
+
variant String
|
|
265
|
+
|
|
266
|
+
variant Float
|
|
267
|
+
|
|
268
|
+
variant Stagehand::Internal::Type::Boolean
|
|
269
|
+
|
|
270
|
+
# @!method self.variants
|
|
271
|
+
# @return [Array(String, Float, Boolean)]
|
|
272
|
+
end
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
# @!method self.variants
|
|
276
|
+
# @return [Array(String, Float, Boolean, Stagehand::Models::SessionExecuteParams::ExecuteOptions::Variable::UnionMember3)]
|
|
277
|
+
end
|
|
223
278
|
end
|
|
224
279
|
|
|
225
280
|
# Whether to stream the response via SSE
|
|
@@ -60,6 +60,12 @@ module Stagehand
|
|
|
60
60
|
# @param request_options [Stagehand::RequestOptions, Hash{Symbol=>Object}]
|
|
61
61
|
|
|
62
62
|
class Options < Stagehand::Internal::Type::BaseModel
|
|
63
|
+
# @!attribute ignore_selectors
|
|
64
|
+
# Selectors for elements and subtrees that should be excluded from extraction
|
|
65
|
+
#
|
|
66
|
+
# @return [Array<String>, nil]
|
|
67
|
+
optional :ignore_selectors, Stagehand::Internal::Type::ArrayOf[String], api_name: :ignoreSelectors
|
|
68
|
+
|
|
63
69
|
# @!attribute model
|
|
64
70
|
# Model configuration object or model name string (e.g., 'openai/gpt-5-nano')
|
|
65
71
|
#
|
|
@@ -78,7 +84,9 @@ module Stagehand
|
|
|
78
84
|
# @return [Float, nil]
|
|
79
85
|
optional :timeout, Float
|
|
80
86
|
|
|
81
|
-
# @!method initialize(model: nil, selector: nil, timeout: nil)
|
|
87
|
+
# @!method initialize(ignore_selectors: nil, model: nil, selector: nil, timeout: nil)
|
|
88
|
+
# @param ignore_selectors [Array<String>] Selectors for elements and subtrees that should be excluded from extraction
|
|
89
|
+
#
|
|
82
90
|
# @param model [Stagehand::Models::ModelConfig, String] Model configuration object or model name string (e.g., 'openai/gpt-5-nano')
|
|
83
91
|
#
|
|
84
92
|
# @param selector [String] CSS selector to scope extraction to a specific element
|
|
@@ -353,6 +353,10 @@ module Stagehand
|
|
|
353
353
|
optional :keep_alive, Stagehand::Internal::Type::Boolean, api_name: :keepAlive
|
|
354
354
|
|
|
355
355
|
# @!attribute project_id
|
|
356
|
+
# @deprecated
|
|
357
|
+
#
|
|
358
|
+
# Deprecated. Browserbase API keys are now project-scoped, so this field is no
|
|
359
|
+
# longer required.
|
|
356
360
|
#
|
|
357
361
|
# @return [String, nil]
|
|
358
362
|
optional :project_id, String, api_name: :projectId
|
|
@@ -380,13 +384,24 @@ module Stagehand
|
|
|
380
384
|
api_name: :userMetadata
|
|
381
385
|
|
|
382
386
|
# @!method initialize(browser_settings: nil, extension_id: nil, keep_alive: nil, project_id: nil, proxies: nil, region: nil, timeout: nil, user_metadata: nil)
|
|
387
|
+
# Some parameter documentations has been truncated, see
|
|
388
|
+
# {Stagehand::Models::SessionStartParams::BrowserbaseSessionCreateParams} for more
|
|
389
|
+
# details.
|
|
390
|
+
#
|
|
383
391
|
# @param browser_settings [Stagehand::Models::SessionStartParams::BrowserbaseSessionCreateParams::BrowserSettings]
|
|
392
|
+
#
|
|
384
393
|
# @param extension_id [String]
|
|
394
|
+
#
|
|
385
395
|
# @param keep_alive [Boolean]
|
|
386
|
-
#
|
|
396
|
+
#
|
|
397
|
+
# @param project_id [String] Deprecated. Browserbase API keys are now project-scoped, so this field is no lon
|
|
398
|
+
#
|
|
387
399
|
# @param proxies [Boolean, Array<Stagehand::Models::SessionStartParams::BrowserbaseSessionCreateParams::Proxies::ProxyConfigList::Browserbase, Stagehand::Models::SessionStartParams::BrowserbaseSessionCreateParams::Proxies::ProxyConfigList::External>]
|
|
400
|
+
#
|
|
388
401
|
# @param region [Symbol, Stagehand::Models::SessionStartParams::BrowserbaseSessionCreateParams::Region]
|
|
402
|
+
#
|
|
389
403
|
# @param timeout [Float]
|
|
404
|
+
#
|
|
390
405
|
# @param user_metadata [Hash{Symbol=>Object}]
|
|
391
406
|
|
|
392
407
|
# @see Stagehand::Models::SessionStartParams::BrowserbaseSessionCreateParams#browser_settings
|
|
@@ -401,6 +416,16 @@ module Stagehand
|
|
|
401
416
|
# @return [Boolean, nil]
|
|
402
417
|
optional :block_ads, Stagehand::Internal::Type::Boolean, api_name: :blockAds
|
|
403
418
|
|
|
419
|
+
# @!attribute captcha_image_selector
|
|
420
|
+
#
|
|
421
|
+
# @return [String, nil]
|
|
422
|
+
optional :captcha_image_selector, String, api_name: :captchaImageSelector
|
|
423
|
+
|
|
424
|
+
# @!attribute captcha_input_selector
|
|
425
|
+
#
|
|
426
|
+
# @return [String, nil]
|
|
427
|
+
optional :captcha_input_selector, String, api_name: :captchaInputSelector
|
|
428
|
+
|
|
404
429
|
# @!attribute context
|
|
405
430
|
#
|
|
406
431
|
# @return [Stagehand::Models::SessionStartParams::BrowserbaseSessionCreateParams::BrowserSettings::Context, nil]
|
|
@@ -423,6 +448,12 @@ module Stagehand
|
|
|
423
448
|
# @return [Boolean, nil]
|
|
424
449
|
optional :log_session, Stagehand::Internal::Type::Boolean, api_name: :logSession
|
|
425
450
|
|
|
451
|
+
# @!attribute os
|
|
452
|
+
#
|
|
453
|
+
# @return [Symbol, Stagehand::Models::SessionStartParams::BrowserbaseSessionCreateParams::BrowserSettings::Os, nil]
|
|
454
|
+
optional :os,
|
|
455
|
+
enum: -> { Stagehand::SessionStartParams::BrowserbaseSessionCreateParams::BrowserSettings::Os }
|
|
456
|
+
|
|
426
457
|
# @!attribute record_session
|
|
427
458
|
#
|
|
428
459
|
# @return [Boolean, nil]
|
|
@@ -433,21 +464,30 @@ module Stagehand
|
|
|
433
464
|
# @return [Boolean, nil]
|
|
434
465
|
optional :solve_captchas, Stagehand::Internal::Type::Boolean, api_name: :solveCaptchas
|
|
435
466
|
|
|
467
|
+
# @!attribute verified
|
|
468
|
+
#
|
|
469
|
+
# @return [Boolean, nil]
|
|
470
|
+
optional :verified, Stagehand::Internal::Type::Boolean
|
|
471
|
+
|
|
436
472
|
# @!attribute viewport
|
|
437
473
|
#
|
|
438
474
|
# @return [Stagehand::Models::SessionStartParams::BrowserbaseSessionCreateParams::BrowserSettings::Viewport, nil]
|
|
439
475
|
optional :viewport,
|
|
440
476
|
-> { Stagehand::SessionStartParams::BrowserbaseSessionCreateParams::BrowserSettings::Viewport }
|
|
441
477
|
|
|
442
|
-
# @!method initialize(advanced_stealth: nil, block_ads: nil, context: nil, extension_id: nil, fingerprint: nil, log_session: nil, record_session: nil, solve_captchas: nil, viewport: nil)
|
|
478
|
+
# @!method initialize(advanced_stealth: nil, block_ads: nil, captcha_image_selector: nil, captcha_input_selector: nil, context: nil, extension_id: nil, fingerprint: nil, log_session: nil, os: nil, record_session: nil, solve_captchas: nil, verified: nil, viewport: nil)
|
|
443
479
|
# @param advanced_stealth [Boolean]
|
|
444
480
|
# @param block_ads [Boolean]
|
|
481
|
+
# @param captcha_image_selector [String]
|
|
482
|
+
# @param captcha_input_selector [String]
|
|
445
483
|
# @param context [Stagehand::Models::SessionStartParams::BrowserbaseSessionCreateParams::BrowserSettings::Context]
|
|
446
484
|
# @param extension_id [String]
|
|
447
485
|
# @param fingerprint [Stagehand::Models::SessionStartParams::BrowserbaseSessionCreateParams::BrowserSettings::Fingerprint]
|
|
448
486
|
# @param log_session [Boolean]
|
|
487
|
+
# @param os [Symbol, Stagehand::Models::SessionStartParams::BrowserbaseSessionCreateParams::BrowserSettings::Os]
|
|
449
488
|
# @param record_session [Boolean]
|
|
450
489
|
# @param solve_captchas [Boolean]
|
|
490
|
+
# @param verified [Boolean]
|
|
451
491
|
# @param viewport [Stagehand::Models::SessionStartParams::BrowserbaseSessionCreateParams::BrowserSettings::Viewport]
|
|
452
492
|
|
|
453
493
|
# @see Stagehand::Models::SessionStartParams::BrowserbaseSessionCreateParams::BrowserSettings#context
|
|
@@ -596,6 +636,20 @@ module Stagehand
|
|
|
596
636
|
end
|
|
597
637
|
end
|
|
598
638
|
|
|
639
|
+
# @see Stagehand::Models::SessionStartParams::BrowserbaseSessionCreateParams::BrowserSettings#os
|
|
640
|
+
module Os
|
|
641
|
+
extend Stagehand::Internal::Type::Enum
|
|
642
|
+
|
|
643
|
+
WINDOWS = :windows
|
|
644
|
+
MAC = :mac
|
|
645
|
+
LINUX = :linux
|
|
646
|
+
MOBILE = :mobile
|
|
647
|
+
TABLET = :tablet
|
|
648
|
+
|
|
649
|
+
# @!method self.values
|
|
650
|
+
# @return [Array<Symbol>]
|
|
651
|
+
end
|
|
652
|
+
|
|
599
653
|
# @see Stagehand::Models::SessionStartParams::BrowserbaseSessionCreateParams::BrowserSettings#viewport
|
|
600
654
|
class Viewport < Stagehand::Internal::Type::BaseModel
|
|
601
655
|
# @!attribute height
|
|
@@ -77,8 +77,11 @@ module Stagehand
|
|
|
77
77
|
path: ["v1/sessions/%1$s/act", id],
|
|
78
78
|
headers: {
|
|
79
79
|
"accept" => "text/event-stream",
|
|
80
|
+
"accept-encoding" => "identity",
|
|
80
81
|
**parsed.slice(*header_params.keys)
|
|
81
|
-
}.transform_keys(
|
|
82
|
+
}.transform_keys(
|
|
83
|
+
header_params
|
|
84
|
+
),
|
|
82
85
|
body: parsed.except(*header_params.keys),
|
|
83
86
|
stream: Stagehand::Internal::Stream,
|
|
84
87
|
model: Stagehand::StreamEvent,
|
|
@@ -193,8 +196,11 @@ module Stagehand
|
|
|
193
196
|
path: ["v1/sessions/%1$s/agentExecute", id],
|
|
194
197
|
headers: {
|
|
195
198
|
"accept" => "text/event-stream",
|
|
199
|
+
"accept-encoding" => "identity",
|
|
196
200
|
**parsed.slice(*header_params.keys)
|
|
197
|
-
}.transform_keys(
|
|
201
|
+
}.transform_keys(
|
|
202
|
+
header_params
|
|
203
|
+
),
|
|
198
204
|
body: parsed.except(*header_params.keys),
|
|
199
205
|
stream: Stagehand::Internal::Stream,
|
|
200
206
|
model: Stagehand::StreamEvent,
|
|
@@ -279,8 +285,11 @@ module Stagehand
|
|
|
279
285
|
path: ["v1/sessions/%1$s/extract", id],
|
|
280
286
|
headers: {
|
|
281
287
|
"accept" => "text/event-stream",
|
|
288
|
+
"accept-encoding" => "identity",
|
|
282
289
|
**parsed.slice(*header_params.keys)
|
|
283
|
-
}.transform_keys(
|
|
290
|
+
}.transform_keys(
|
|
291
|
+
header_params
|
|
292
|
+
),
|
|
284
293
|
body: parsed.except(*header_params.keys),
|
|
285
294
|
stream: Stagehand::Internal::Stream,
|
|
286
295
|
model: Stagehand::StreamEvent,
|
|
@@ -397,8 +406,11 @@ module Stagehand
|
|
|
397
406
|
path: ["v1/sessions/%1$s/observe", id],
|
|
398
407
|
headers: {
|
|
399
408
|
"accept" => "text/event-stream",
|
|
409
|
+
"accept-encoding" => "identity",
|
|
400
410
|
**parsed.slice(*header_params.keys)
|
|
401
|
-
}.transform_keys(
|
|
411
|
+
}.transform_keys(
|
|
412
|
+
header_params
|
|
413
|
+
),
|
|
402
414
|
body: parsed.except(*header_params.keys),
|
|
403
415
|
stream: Stagehand::Internal::Stream,
|
|
404
416
|
model: Stagehand::StreamEvent,
|
data/lib/stagehand/version.rb
CHANGED
data/rbi/stagehand/client.rbi
CHANGED
|
@@ -14,7 +14,7 @@ module Stagehand
|
|
|
14
14
|
sig { returns(String) }
|
|
15
15
|
attr_reader :browserbase_api_key
|
|
16
16
|
|
|
17
|
-
#
|
|
17
|
+
# Deprecated. Browserbase API keys are now project-scoped, so this value is accepted for backwards compatibility and ignored.
|
|
18
18
|
sig { returns(String) }
|
|
19
19
|
attr_reader :browserbase_project_id
|
|
20
20
|
|
|
@@ -63,17 +63,17 @@ module Stagehand
|
|
|
63
63
|
# Your [Browserbase API Key](https://www.browserbase.com/settings) Defaults to
|
|
64
64
|
# `ENV["BROWSERBASE_API_KEY"]`
|
|
65
65
|
browserbase_api_key: ENV["BROWSERBASE_API_KEY"],
|
|
66
|
-
#
|
|
67
|
-
|
|
68
|
-
browserbase_project_id: ENV["BROWSERBASE_PROJECT_ID"],
|
|
66
|
+
# Deprecated. Browserbase API keys are now project-scoped, so this value is accepted for backwards compatibility and ignored.
|
|
67
|
+
browserbase_project_id: nil,
|
|
69
68
|
# Your LLM provider API key (e.g. OPENAI_API_KEY, ANTHROPIC_API_KEY, etc.)
|
|
70
69
|
# Defaults to `ENV["MODEL_API_KEY"]`
|
|
71
70
|
model_api_key: ENV["MODEL_API_KEY"],
|
|
72
71
|
# Server mode to use ("remote" or "local"). Defaults to "remote"
|
|
73
72
|
server: "remote",
|
|
74
73
|
# Override the default base URL for the API, e.g.,
|
|
75
|
-
# `"https://api.example.com/v2/"`. Defaults to `ENV["
|
|
76
|
-
|
|
74
|
+
# `"https://api.example.com/v2/"`. Defaults to `ENV["STAGEHAND_API_URL"]`,
|
|
75
|
+
# then `ENV["STAGEHAND_BASE_URL"]`
|
|
76
|
+
base_url: ENV["STAGEHAND_API_URL"] || ENV["STAGEHAND_BASE_URL"],
|
|
77
77
|
# Max number of retries to attempt after a failed retryable request.
|
|
78
78
|
max_retries: Stagehand::Client::DEFAULT_MAX_RETRIES,
|
|
79
79
|
timeout: Stagehand::Client::DEFAULT_TIMEOUT_IN_SECONDS,
|