stagehand 3.7.1 → 3.19.3

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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +45 -0
  3. data/README.md +3 -3
  4. data/lib/stagehand/internal/stream.rb +2 -11
  5. data/lib/stagehand/internal/util.rb +50 -6
  6. data/lib/stagehand/local.rb +5 -5
  7. data/lib/stagehand/models/model_config.rb +9 -1
  8. data/lib/stagehand/models/session_act_params.rb +63 -5
  9. data/lib/stagehand/models/session_end_params.rb +9 -1
  10. data/lib/stagehand/models/session_execute_params.rb +26 -2
  11. data/lib/stagehand/models/session_extract_params.rb +9 -1
  12. data/lib/stagehand/models/session_navigate_params.rb +9 -1
  13. data/lib/stagehand/models/session_observe_params.rb +69 -2
  14. data/lib/stagehand/models/session_replay_params.rb +9 -1
  15. data/lib/stagehand/models/session_start_params.rb +7 -1
  16. data/lib/stagehand/models/stream_event.rb +2 -1
  17. data/lib/stagehand/version.rb +1 -1
  18. data/rbi/stagehand/internal/util.rbi +28 -0
  19. data/rbi/stagehand/models/model_config.rbi +11 -0
  20. data/rbi/stagehand/models/session_act_params.rbi +144 -6
  21. data/rbi/stagehand/models/session_end_params.rbi +8 -0
  22. data/rbi/stagehand/models/session_execute_params.rbi +33 -3
  23. data/rbi/stagehand/models/session_extract_params.rbi +8 -0
  24. data/rbi/stagehand/models/session_navigate_params.rbi +8 -0
  25. data/rbi/stagehand/models/session_observe_params.rbi +156 -3
  26. data/rbi/stagehand/models/session_replay_params.rbi +8 -0
  27. data/rbi/stagehand/models/session_start_params.rbi +9 -0
  28. data/rbi/stagehand/models/stream_event.rbi +2 -1
  29. data/sig/stagehand/internal/util.rbs +14 -0
  30. data/sig/stagehand/models/model_config.rbs +7 -0
  31. data/sig/stagehand/models/session_act_params.rbs +56 -5
  32. data/sig/stagehand/models/session_end_params.rbs +5 -0
  33. data/sig/stagehand/models/session_execute_params.rbs +26 -3
  34. data/sig/stagehand/models/session_extract_params.rbs +5 -0
  35. data/sig/stagehand/models/session_navigate_params.rbs +5 -0
  36. data/sig/stagehand/models/session_observe_params.rbs +61 -3
  37. data/sig/stagehand/models/session_replay_params.rbs +5 -0
  38. data/sig/stagehand/models/session_start_params.rbs +7 -0
  39. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87ccf4bfcfc723469ff68db45b650d9f2702c6692905a8f6a42e7456d6d37b63
4
- data.tar.gz: dbcfc350b71c0a0d89cad72696fcde9fc3f506d425fedd56e2e611b176070a73
3
+ metadata.gz: f3995180e65110d8a64695b7be8cb095b24e8d6fb3bc2627f13df4c0acaa15f2
4
+ data.tar.gz: a0b8bcd2648d2429b55c13b50d60fb7ec46da97118390900d1acfe0989e728d4
5
5
  SHA512:
6
- metadata.gz: 1bafc8973dd2a0844797e67c0ecb04fdf0a3b8245ff0639af4f9334da95cdfbc6701f00ab8519ae07a998478383b14c633c8e3bd823c991caa4623ac5b9ace0d
7
- data.tar.gz: 2e35f3d9adace66379d78c8631d271932d040ccc2aa190a793f074e37e1ea737c766424f21ebd2e6bfbd49687d9073e223615db052b624ff7488c641e3dedf81
6
+ metadata.gz: 83eae8bebac5087cda9551141db3d62bff7a0caa065ff675799610237d3ebf5114b62bb519403a3063e147b9384721d6bc0fdca28ce222c08691326f0a8b5e82
7
+ data.tar.gz: 7461914b6798606c6f0a672074ed3eaba504a82794e97becf1974de15cf701ce25ceec987d6969bb833d2ef098a5562da41f7faad6b1e871c75bba3ed4b4cda9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,50 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.19.3 (2026-04-03)
4
+
5
+ Full Changelog: [v3.18.0...v3.19.3](https://github.com/browserbase/stagehand-ruby/compare/v3.18.0...v3.19.3)
6
+
7
+ ### Features
8
+
9
+ * Replace default model used in server-v3 api spec examples ([0460af2](https://github.com/browserbase/stagehand-ruby/commit/0460af273ab6ba521a01847fe943032b619f7922))
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * align path encoding with RFC 3986 section 3.3 ([4f07e2e](https://github.com/browserbase/stagehand-ruby/commit/4f07e2eb4439a53ed1d830f0471b563656f19832))
15
+ * **internal:** correct multipart form field name encoding ([2478726](https://github.com/browserbase/stagehand-ruby/commit/247872691f0c955d19b06cdfac5a4feb13477c1f))
16
+ * variable name typo ([41c9b71](https://github.com/browserbase/stagehand-ruby/commit/41c9b719de177dc28c3f5b167bb96a136336866d))
17
+
18
+
19
+ ### Chores
20
+
21
+ * **ci:** support opting out of skipping builds on metadata-only commits ([cb20c91](https://github.com/browserbase/stagehand-ruby/commit/cb20c91371c9be0282616f9137e51a2414b8a969))
22
+
23
+ ## 3.18.0 (2026-03-25)
24
+
25
+ Full Changelog: [v3.7.1...v3.18.0](https://github.com/browserbase/stagehand-ruby/compare/v3.7.1...v3.18.0)
26
+
27
+ ### Features
28
+
29
+ * [fix]: add `useSearch` & `toolTimeout` to stainless types ([e5bedb8](https://github.com/browserbase/stagehand-ruby/commit/e5bedb88ac67d34a6db440e470e3eb964205e558))
30
+ * [STG-1607] Yield finished SSE event instead of silently dropping it ([d5ffd2d](https://github.com/browserbase/stagehand-ruby/commit/d5ffd2d0ed6495673ef80ba0e1649bd1c1afa815))
31
+ * Add explicit SSE event names for local v3 streaming ([5be6d12](https://github.com/browserbase/stagehand-ruby/commit/5be6d1293763ecb7f0268884784475986de2915c))
32
+ * Add missing cdpHeaders field to v3 server openapi spec ([de6457f](https://github.com/browserbase/stagehand-ruby/commit/de6457f121764ffbadac51ec2a6103c27dbde338))
33
+ * Include LLM headers in ModelConfig ([23cb4ea](https://github.com/browserbase/stagehand-ruby/commit/23cb4ea1319287992f1174c2b8fa2eff5fdfc5c4))
34
+ * Revert broken finished SSE yield config ([1de4c00](https://github.com/browserbase/stagehand-ruby/commit/1de4c00c0b72936813fcd3e0499b51b1f135f33d))
35
+ * variables for observe ([a9d6970](https://github.com/browserbase/stagehand-ruby/commit/a9d6970e7f43f1d69eddb42a14f09fb7f9158b29))
36
+
37
+
38
+ ### Chores
39
+
40
+ * **ci:** add build step ([ed6573f](https://github.com/browserbase/stagehand-ruby/commit/ed6573f2ddab4f5f51d1262480cb663da5e003d0))
41
+ * **ci:** skip lint on metadata-only changes ([079a802](https://github.com/browserbase/stagehand-ruby/commit/079a8028edf4e9dd09517363b0c1a3b16ed86865))
42
+ * **ci:** skip uploading artifacts on stainless-internal branches ([3a7e90b](https://github.com/browserbase/stagehand-ruby/commit/3a7e90bc8dd9f983dbbc7be16f997dd2dc02c3c0))
43
+ * **internal:** codegen related update ([f714af2](https://github.com/browserbase/stagehand-ruby/commit/f714af2d7d5b9b822362aa10f6f6facab3332eaf))
44
+ * **internal:** codegen related update ([ed9fab1](https://github.com/browserbase/stagehand-ruby/commit/ed9fab1f726c05ef48d4a55507b09212d7ced713))
45
+ * **internal:** tweak CI branches ([85b5b46](https://github.com/browserbase/stagehand-ruby/commit/85b5b4656c921f0784d05b27a3c4773b05b51cc6))
46
+ * **internal:** update gitignore ([b4bc8a8](https://github.com/browserbase/stagehand-ruby/commit/b4bc8a8ae60ff252080d4bfcd0fc6af26dc95e74))
47
+
3
48
  ## 3.7.1 (2026-02-27)
4
49
 
5
50
  Full Changelog: [v3.7.0...v3.7.1](https://github.com/browserbase/stagehand-ruby/compare/v3.7.0...v3.7.1)
data/README.md CHANGED
@@ -213,7 +213,7 @@ When the library is unable to connect to the API, or if the API returns a non-su
213
213
 
214
214
  ```ruby
215
215
  begin
216
- session = stagehand.sessions.start(model_name: "anthropic/claude-sonnet-4-6")
216
+ session = stagehand.sessions.start(model_name: "openai/gpt-5.4-mini")
217
217
  rescue Stagehand::Errors::APIConnectionError => e
218
218
  puts("The server could not be reached")
219
219
  puts(e.cause) # an underlying Exception, likely raised within `net/http`
@@ -256,7 +256,7 @@ stagehand = Stagehand::Client.new(
256
256
  )
257
257
 
258
258
  # Or, configure per-request:
259
- stagehand.sessions.start(model_name: "anthropic/claude-sonnet-4-6", request_options: {max_retries: 5})
259
+ stagehand.sessions.start(model_name: "openai/gpt-5.4-mini", request_options: {max_retries: 5})
260
260
  ```
261
261
 
262
262
  ### Timeouts
@@ -270,7 +270,7 @@ stagehand = Stagehand::Client.new(
270
270
  )
271
271
 
272
272
  # Or, configure per-request:
273
- stagehand.sessions.start(model_name: "anthropic/claude-sonnet-4-6", request_options: {timeout: 5})
273
+ stagehand.sessions.start(model_name: "openai/gpt-5.4-mini", request_options: {timeout: 5})
274
274
  ```
275
275
 
276
276
  On timeout, `Stagehand::Errors::APITimeoutError` is raised.
@@ -15,18 +15,10 @@ module Stagehand
15
15
  #
16
16
  # @return [Enumerable<generic<Elem>>]
17
17
  private def iterator
18
- # rubocop:disable Metrics/BlockLength
19
18
  @iterator ||= Stagehand::Internal::Util.chain_fused(@stream) do |y|
20
- consume = false
21
-
22
19
  @stream.each do |msg|
23
- next if consume
24
-
25
20
  case msg
26
- in {data: String => data} if data.start_with?("{\"data\":{\"status\":\"finished\"")
27
- consume = true
28
- next
29
- in {data: String => data} if data.start_with?("error")
21
+ in {event: "error", data: String => data}
30
22
  decoded = Kernel.then do
31
23
  JSON.parse(data, symbolize_names: true)
32
24
  rescue JSON::ParserError
@@ -41,7 +33,7 @@ module Stagehand
41
33
  response: @response
42
34
  )
43
35
  raise err
44
- in {event: nil, data: String => data}
36
+ in {event: "starting" | "connected" | "running" | "finished", data: String => data}
45
37
  decoded = JSON.parse(data, symbolize_names: true)
46
38
  unwrapped = Stagehand::Internal::Util.dig(decoded, @unwrap)
47
39
  y << Stagehand::Internal::Type::Converter.coerce(@model, unwrapped)
@@ -49,7 +41,6 @@ module Stagehand
49
41
  end
50
42
  end
51
43
  end
52
- # rubocop:enable Metrics/BlockLength
53
44
  end
54
45
  end
55
46
  end
@@ -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 #{data.inspect}"
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 { ERB::Util.url_encode(_1) }
276
+ encoded = interpolations.map { encode_path(_1) }
263
277
  format(p, *encoded)
264
278
  end
265
279
  end
@@ -490,6 +504,37 @@ module Stagehand
490
504
  JSONL_CONTENT = %r{^application/(:?x-(?:n|l)djson)|(:?(?:x-)?jsonl)}
491
505
 
492
506
  class << self
507
+ # @api private
508
+ #
509
+ # @param query [Hash{Symbol=>Object}]
510
+ #
511
+ # @return [Hash{Symbol=>Object}]
512
+ def encode_query_params(query)
513
+ out = {}
514
+ query.each { write_query_param_element!(out, _1, _2) }
515
+ out
516
+ end
517
+
518
+ # @api private
519
+ #
520
+ # @param collection [Hash{Symbol=>Object}]
521
+ # @param key [String]
522
+ # @param element [Object]
523
+ #
524
+ # @return [nil]
525
+ private def write_query_param_element!(collection, key, element)
526
+ case element
527
+ in Hash
528
+ element.each do |name, value|
529
+ write_query_param_element!(collection, "#{key}[#{name}]", value)
530
+ end
531
+ in Array
532
+ collection[key] = element.map(&:to_s).join(",")
533
+ else
534
+ collection[key] = element.to_s
535
+ end
536
+ end
537
+
493
538
  # @api private
494
539
  #
495
540
  # @param y [Enumerator::Yielder]
@@ -540,16 +585,15 @@ module Stagehand
540
585
  y << "Content-Disposition: form-data"
541
586
 
542
587
  unless key.nil?
543
- name = ERB::Util.url_encode(key.to_s)
544
- y << "; name=\"#{name}\""
588
+ y << "; name=\"#{key}\""
545
589
  end
546
590
 
547
591
  case val
548
592
  in Stagehand::FilePart unless val.filename.nil?
549
- filename = ERB::Util.url_encode(val.filename)
593
+ filename = encode_path(val.filename)
550
594
  y << "; filename=\"#{filename}\""
551
595
  in Pathname | IO
552
- filename = ERB::Util.url_encode(::File.basename(val.to_path))
596
+ filename = encode_path(::File.basename(val.to_path))
553
597
  y << "; filename=\"#{filename}\""
554
598
  else
555
599
  end
@@ -85,7 +85,7 @@ module Stagehand
85
85
 
86
86
  def binary_filename
87
87
  platform, arch = platform_tag
88
- name = "stagehand-server-#{platform}-#{arch}"
88
+ name = "stagehand-server-v3-#{platform}-#{arch}"
89
89
  name += ".exe" if platform == "win32"
90
90
  name
91
91
  end
@@ -131,9 +131,9 @@ module Stagehand
131
131
 
132
132
  def resolve_version(version)
133
133
  return fetch_latest_tag if version.empty? || version == "latest"
134
- return version if version.start_with?("stagehand-server/")
134
+ return version if version.start_with?("stagehand-server-v3/")
135
135
 
136
- "stagehand-server/#{version}"
136
+ "stagehand-server-v3/#{version}"
137
137
  end
138
138
 
139
139
  def fetch_latest_tag
@@ -148,9 +148,9 @@ module Stagehand
148
148
  releases = JSON.parse(response.body.to_s)
149
149
  releases.each do |release|
150
150
  tag = release["tag_name"]
151
- return tag if tag.is_a?(String) && tag.start_with?("stagehand-server/")
151
+ return tag if tag.is_a?(String) && tag.start_with?("stagehand-server-v3/")
152
152
  end
153
- raise "Failed to find stagehand-server release tag"
153
+ raise "Failed to find stagehand-server-v3 release tag"
154
154
  end
155
155
 
156
156
  def download_binary(tag, dest_path)
@@ -21,19 +21,27 @@ module Stagehand
21
21
  # @return [String, nil]
22
22
  optional :base_url, String, api_name: :baseURL
23
23
 
24
+ # @!attribute headers
25
+ # Custom headers sent with every request to the model provider
26
+ #
27
+ # @return [Hash{Symbol=>String}, nil]
28
+ optional :headers, Stagehand::Internal::Type::HashOf[String]
29
+
24
30
  # @!attribute provider
25
31
  # AI provider for the model (or provide a baseURL endpoint instead)
26
32
  #
27
33
  # @return [Symbol, Stagehand::Models::ModelConfig::Provider, nil]
28
34
  optional :provider, enum: -> { Stagehand::ModelConfig::Provider }
29
35
 
30
- # @!method initialize(model_name:, api_key: nil, base_url: nil, provider: nil)
36
+ # @!method initialize(model_name:, api_key: nil, base_url: nil, headers: nil, provider: nil)
31
37
  # @param model_name [String] Model name string with provider prefix (e.g., 'openai/gpt-5-nano')
32
38
  #
33
39
  # @param api_key [String] API key for the model provider
34
40
  #
35
41
  # @param base_url [String] Base URL for the model provider
36
42
  #
43
+ # @param headers [Hash{Symbol=>String}] Custom headers sent with every request to the model provider
44
+ #
37
45
  # @param provider [Symbol, Stagehand::Models::ModelConfig::Provider] AI provider for the model (or provide a baseURL endpoint instead)
38
46
 
39
47
  # AI provider for the model (or provide a baseURL endpoint instead)
@@ -9,6 +9,12 @@ module Stagehand
9
9
  extend Stagehand::Internal::Type::RequestParameters::Converter
10
10
  include Stagehand::Internal::Type::RequestParameters
11
11
 
12
+ # @!attribute id
13
+ # Unique session identifier
14
+ #
15
+ # @return [String]
16
+ required :id, String
17
+
12
18
  # @!attribute input
13
19
  # Natural language instruction or Action object
14
20
  #
@@ -32,7 +38,9 @@ module Stagehand
32
38
  # @return [Symbol, Stagehand::Models::SessionActParams::XStreamResponse, nil]
33
39
  optional :x_stream_response, enum: -> { Stagehand::SessionActParams::XStreamResponse }
34
40
 
35
- # @!method initialize(input:, frame_id: nil, options: nil, x_stream_response: nil, request_options: {})
41
+ # @!method initialize(id:, input:, frame_id: nil, options: nil, x_stream_response: nil, request_options: {})
42
+ # @param id [String] Unique session identifier
43
+ #
36
44
  # @param input [String, Stagehand::Models::Action] Natural language instruction or Action object
37
45
  #
38
46
  # @param frame_id [String, nil] Target frame ID for the action
@@ -70,17 +78,22 @@ module Stagehand
70
78
  optional :timeout, Float
71
79
 
72
80
  # @!attribute variables
73
- # Variables to substitute in the action instruction
81
+ # Variables to substitute in the action instruction. Accepts flat primitives or {
82
+ # value, description? } objects.
74
83
  #
75
- # @return [Hash{Symbol=>String}, nil]
76
- optional :variables, Stagehand::Internal::Type::HashOf[String]
84
+ # @return [Hash{Symbol=>String, Float, Boolean, Stagehand::Models::SessionActParams::Options::Variable::UnionMember3}, nil]
85
+ optional :variables,
86
+ -> { Stagehand::Internal::Type::HashOf[union: Stagehand::SessionActParams::Options::Variable] }
77
87
 
78
88
  # @!method initialize(model: nil, timeout: nil, variables: nil)
89
+ # Some parameter documentations has been truncated, see
90
+ # {Stagehand::Models::SessionActParams::Options} for more details.
91
+ #
79
92
  # @param model [Stagehand::Models::ModelConfig, String] Model configuration object or model name string (e.g., 'openai/gpt-5-nano')
80
93
  #
81
94
  # @param timeout [Float] Timeout in ms for the action
82
95
  #
83
- # @param variables [Hash{Symbol=>String}] Variables to substitute in the action instruction
96
+ # @param variables [Hash{Symbol=>String, Float, Boolean, Stagehand::Models::SessionActParams::Options::Variable::UnionMember3}] Variables to substitute in the action instruction. Accepts flat primitives or {
84
97
 
85
98
  # Model configuration object or model name string (e.g., 'openai/gpt-5-nano')
86
99
  #
@@ -95,6 +108,51 @@ module Stagehand
95
108
  # @!method self.variants
96
109
  # @return [Array(Stagehand::Models::ModelConfig, String)]
97
110
  end
111
+
112
+ module Variable
113
+ extend Stagehand::Internal::Type::Union
114
+
115
+ variant String
116
+
117
+ variant Float
118
+
119
+ variant Stagehand::Internal::Type::Boolean
120
+
121
+ variant -> { Stagehand::SessionActParams::Options::Variable::UnionMember3 }
122
+
123
+ class UnionMember3 < Stagehand::Internal::Type::BaseModel
124
+ # @!attribute value
125
+ #
126
+ # @return [String, Float, Boolean]
127
+ required :value, union: -> { Stagehand::SessionActParams::Options::Variable::UnionMember3::Value }
128
+
129
+ # @!attribute description
130
+ #
131
+ # @return [String, nil]
132
+ optional :description, String
133
+
134
+ # @!method initialize(value:, description: nil)
135
+ # @param value [String, Float, Boolean]
136
+ # @param description [String]
137
+
138
+ # @see Stagehand::Models::SessionActParams::Options::Variable::UnionMember3#value
139
+ module Value
140
+ extend Stagehand::Internal::Type::Union
141
+
142
+ variant String
143
+
144
+ variant Float
145
+
146
+ variant Stagehand::Internal::Type::Boolean
147
+
148
+ # @!method self.variants
149
+ # @return [Array(String, Float, Boolean)]
150
+ end
151
+ end
152
+
153
+ # @!method self.variants
154
+ # @return [Array(String, Float, Boolean, Stagehand::Models::SessionActParams::Options::Variable::UnionMember3)]
155
+ end
98
156
  end
99
157
 
100
158
  # Whether to stream the response via SSE
@@ -7,13 +7,21 @@ module Stagehand
7
7
  extend Stagehand::Internal::Type::RequestParameters::Converter
8
8
  include Stagehand::Internal::Type::RequestParameters
9
9
 
10
+ # @!attribute id
11
+ # Unique session identifier
12
+ #
13
+ # @return [String]
14
+ required :id, String
15
+
10
16
  # @!attribute x_stream_response
11
17
  # Whether to stream the response via SSE
12
18
  #
13
19
  # @return [Symbol, Stagehand::Models::SessionEndParams::XStreamResponse, nil]
14
20
  optional :x_stream_response, enum: -> { Stagehand::SessionEndParams::XStreamResponse }
15
21
 
16
- # @!method initialize(x_stream_response: nil, request_options: {})
22
+ # @!method initialize(id:, x_stream_response: nil, request_options: {})
23
+ # @param id [String] Unique session identifier
24
+ #
17
25
  # @param x_stream_response [Symbol, Stagehand::Models::SessionEndParams::XStreamResponse] Whether to stream the response via SSE
18
26
  #
19
27
  # @param request_options [Stagehand::RequestOptions, Hash{Symbol=>Object}]
@@ -9,6 +9,12 @@ module Stagehand
9
9
  extend Stagehand::Internal::Type::RequestParameters::Converter
10
10
  include Stagehand::Internal::Type::RequestParameters
11
11
 
12
+ # @!attribute id
13
+ # Unique session identifier
14
+ #
15
+ # @return [String]
16
+ required :id, String
17
+
12
18
  # @!attribute agent_config
13
19
  #
14
20
  # @return [Stagehand::Models::SessionExecuteParams::AgentConfig]
@@ -39,7 +45,9 @@ module Stagehand
39
45
  # @return [Symbol, Stagehand::Models::SessionExecuteParams::XStreamResponse, nil]
40
46
  optional :x_stream_response, enum: -> { Stagehand::SessionExecuteParams::XStreamResponse }
41
47
 
42
- # @!method initialize(agent_config:, execute_options:, frame_id: nil, should_cache: nil, x_stream_response: nil, request_options: {})
48
+ # @!method initialize(id:, agent_config:, execute_options:, frame_id: nil, should_cache: nil, x_stream_response: nil, request_options: {})
49
+ # @param id [String] Unique session identifier
50
+ #
43
51
  # @param agent_config [Stagehand::Models::SessionExecuteParams::AgentConfig]
44
52
  #
45
53
  # @param execute_options [Stagehand::Models::SessionExecuteParams::ExecuteOptions]
@@ -190,12 +198,28 @@ module Stagehand
190
198
  # @return [Float, nil]
191
199
  optional :max_steps, Float, api_name: :maxSteps
192
200
 
193
- # @!method initialize(instruction:, highlight_cursor: nil, max_steps: nil)
201
+ # @!attribute tool_timeout
202
+ # Timeout in milliseconds for each agent tool call
203
+ #
204
+ # @return [Float, nil]
205
+ optional :tool_timeout, Float, api_name: :toolTimeout
206
+
207
+ # @!attribute use_search
208
+ # Whether to enable the web search tool powered by Browserbase Search API
209
+ #
210
+ # @return [Boolean, nil]
211
+ optional :use_search, Stagehand::Internal::Type::Boolean, api_name: :useSearch
212
+
213
+ # @!method initialize(instruction:, highlight_cursor: nil, max_steps: nil, tool_timeout: nil, use_search: nil)
194
214
  # @param instruction [String] Natural language instruction for the agent
195
215
  #
196
216
  # @param highlight_cursor [Boolean] Whether to visually highlight the cursor during execution
197
217
  #
198
218
  # @param max_steps [Float] Maximum number of steps the agent can take
219
+ #
220
+ # @param tool_timeout [Float] Timeout in milliseconds for each agent tool call
221
+ #
222
+ # @param use_search [Boolean] Whether to enable the web search tool powered by Browserbase Search API
199
223
  end
200
224
 
201
225
  # Whether to stream the response via SSE
@@ -9,6 +9,12 @@ module Stagehand
9
9
  extend Stagehand::Internal::Type::RequestParameters::Converter
10
10
  include Stagehand::Internal::Type::RequestParameters
11
11
 
12
+ # @!attribute id
13
+ # Unique session identifier
14
+ #
15
+ # @return [String]
16
+ required :id, String
17
+
12
18
  # @!attribute frame_id
13
19
  # Target frame ID for the extraction
14
20
  #
@@ -38,7 +44,9 @@ module Stagehand
38
44
  # @return [Symbol, Stagehand::Models::SessionExtractParams::XStreamResponse, nil]
39
45
  optional :x_stream_response, enum: -> { Stagehand::SessionExtractParams::XStreamResponse }
40
46
 
41
- # @!method initialize(frame_id: nil, instruction: nil, options: nil, schema: nil, x_stream_response: nil, request_options: {})
47
+ # @!method initialize(id:, frame_id: nil, instruction: nil, options: nil, schema: nil, x_stream_response: nil, request_options: {})
48
+ # @param id [String] Unique session identifier
49
+ #
42
50
  # @param frame_id [String, nil] Target frame ID for the extraction
43
51
  #
44
52
  # @param instruction [String] Natural language instruction for what to extract
@@ -7,6 +7,12 @@ module Stagehand
7
7
  extend Stagehand::Internal::Type::RequestParameters::Converter
8
8
  include Stagehand::Internal::Type::RequestParameters
9
9
 
10
+ # @!attribute id
11
+ # Unique session identifier
12
+ #
13
+ # @return [String]
14
+ required :id, String
15
+
10
16
  # @!attribute url
11
17
  # URL to navigate to
12
18
  #
@@ -36,7 +42,9 @@ module Stagehand
36
42
  # @return [Symbol, Stagehand::Models::SessionNavigateParams::XStreamResponse, nil]
37
43
  optional :x_stream_response, enum: -> { Stagehand::SessionNavigateParams::XStreamResponse }
38
44
 
39
- # @!method initialize(url:, frame_id: nil, options: nil, stream_response: nil, x_stream_response: nil, request_options: {})
45
+ # @!method initialize(id:, url:, frame_id: nil, options: nil, stream_response: nil, x_stream_response: nil, request_options: {})
46
+ # @param id [String] Unique session identifier
47
+ #
40
48
  # @param url [String] URL to navigate to
41
49
  #
42
50
  # @param frame_id [String, nil] Target frame ID for the navigation
@@ -9,6 +9,12 @@ module Stagehand
9
9
  extend Stagehand::Internal::Type::RequestParameters::Converter
10
10
  include Stagehand::Internal::Type::RequestParameters
11
11
 
12
+ # @!attribute id
13
+ # Unique session identifier
14
+ #
15
+ # @return [String]
16
+ required :id, String
17
+
12
18
  # @!attribute frame_id
13
19
  # Target frame ID for the observation
14
20
  #
@@ -32,7 +38,9 @@ module Stagehand
32
38
  # @return [Symbol, Stagehand::Models::SessionObserveParams::XStreamResponse, nil]
33
39
  optional :x_stream_response, enum: -> { Stagehand::SessionObserveParams::XStreamResponse }
34
40
 
35
- # @!method initialize(frame_id: nil, instruction: nil, options: nil, x_stream_response: nil, request_options: {})
41
+ # @!method initialize(id:, frame_id: nil, instruction: nil, options: nil, x_stream_response: nil, request_options: {})
42
+ # @param id [String] Unique session identifier
43
+ #
36
44
  # @param frame_id [String, nil] Target frame ID for the observation
37
45
  #
38
46
  # @param instruction [String] Natural language instruction for what actions to find
@@ -62,12 +70,26 @@ module Stagehand
62
70
  # @return [Float, nil]
63
71
  optional :timeout, Float
64
72
 
65
- # @!method initialize(model: nil, selector: nil, timeout: nil)
73
+ # @!attribute variables
74
+ # Variables whose names are exposed to the model so observe() returns
75
+ # %variableName% placeholders in suggested action arguments instead of literal
76
+ # values. Accepts flat primitives or { value, description? } objects.
77
+ #
78
+ # @return [Hash{Symbol=>String, Float, Boolean, Stagehand::Models::SessionObserveParams::Options::Variable::UnionMember3}, nil]
79
+ optional :variables,
80
+ -> { Stagehand::Internal::Type::HashOf[union: Stagehand::SessionObserveParams::Options::Variable] }
81
+
82
+ # @!method initialize(model: nil, selector: nil, timeout: nil, variables: nil)
83
+ # Some parameter documentations has been truncated, see
84
+ # {Stagehand::Models::SessionObserveParams::Options} for more details.
85
+ #
66
86
  # @param model [Stagehand::Models::ModelConfig, String] Model configuration object or model name string (e.g., 'openai/gpt-5-nano')
67
87
  #
68
88
  # @param selector [String] CSS selector to scope observation to a specific element
69
89
  #
70
90
  # @param timeout [Float] Timeout in ms for the observation
91
+ #
92
+ # @param variables [Hash{Symbol=>String, Float, Boolean, Stagehand::Models::SessionObserveParams::Options::Variable::UnionMember3}] Variables whose names are exposed to the model so observe() returns %variableNam
71
93
 
72
94
  # Model configuration object or model name string (e.g., 'openai/gpt-5-nano')
73
95
  #
@@ -82,6 +104,51 @@ module Stagehand
82
104
  # @!method self.variants
83
105
  # @return [Array(Stagehand::Models::ModelConfig, String)]
84
106
  end
107
+
108
+ module Variable
109
+ extend Stagehand::Internal::Type::Union
110
+
111
+ variant String
112
+
113
+ variant Float
114
+
115
+ variant Stagehand::Internal::Type::Boolean
116
+
117
+ variant -> { Stagehand::SessionObserveParams::Options::Variable::UnionMember3 }
118
+
119
+ class UnionMember3 < Stagehand::Internal::Type::BaseModel
120
+ # @!attribute value
121
+ #
122
+ # @return [String, Float, Boolean]
123
+ required :value, union: -> { Stagehand::SessionObserveParams::Options::Variable::UnionMember3::Value }
124
+
125
+ # @!attribute description
126
+ #
127
+ # @return [String, nil]
128
+ optional :description, String
129
+
130
+ # @!method initialize(value:, description: nil)
131
+ # @param value [String, Float, Boolean]
132
+ # @param description [String]
133
+
134
+ # @see Stagehand::Models::SessionObserveParams::Options::Variable::UnionMember3#value
135
+ module Value
136
+ extend Stagehand::Internal::Type::Union
137
+
138
+ variant String
139
+
140
+ variant Float
141
+
142
+ variant Stagehand::Internal::Type::Boolean
143
+
144
+ # @!method self.variants
145
+ # @return [Array(String, Float, Boolean)]
146
+ end
147
+ end
148
+
149
+ # @!method self.variants
150
+ # @return [Array(String, Float, Boolean, Stagehand::Models::SessionObserveParams::Options::Variable::UnionMember3)]
151
+ end
85
152
  end
86
153
 
87
154
  # Whether to stream the response via SSE
@@ -7,13 +7,21 @@ module Stagehand
7
7
  extend Stagehand::Internal::Type::RequestParameters::Converter
8
8
  include Stagehand::Internal::Type::RequestParameters
9
9
 
10
+ # @!attribute id
11
+ # Unique session identifier
12
+ #
13
+ # @return [String]
14
+ required :id, String
15
+
10
16
  # @!attribute x_stream_response
11
17
  # Whether to stream the response via SSE
12
18
  #
13
19
  # @return [Symbol, Stagehand::Models::SessionReplayParams::XStreamResponse, nil]
14
20
  optional :x_stream_response, enum: -> { Stagehand::SessionReplayParams::XStreamResponse }
15
21
 
16
- # @!method initialize(x_stream_response: nil, request_options: {})
22
+ # @!method initialize(id:, x_stream_response: nil, request_options: {})
23
+ # @param id [String] Unique session identifier
24
+ #
17
25
  # @param x_stream_response [Symbol, Stagehand::Models::SessionReplayParams::XStreamResponse] Whether to stream the response via SSE
18
26
  #
19
27
  # @param request_options [Stagehand::RequestOptions, Hash{Symbol=>Object}]