@@ -34,9 +34,9 @@ stagehand = Stagehand::Client.new(
3434 model_api_key: ENV [" MODEL_API_KEY" ] # This is the default and can be omitted
3535)
3636
37- response = stagehand.sessions.act( " 00000000-your-session-id-000000000000 " , input: " click the first link on the page " )
37+ response = stagehand.sessions.start
3838
39- puts (response.actions )
39+ puts (response)
4040```
4141
4242### Handling errors
@@ -45,10 +45,7 @@ When the library is unable to connect to the API, or if the API returns a non-su
4545
4646``` ruby
4747begin
48- session = stagehand.sessions.start(
49- browserbase_api_key: " your Browserbase API key" ,
50- browserbase_project_id: " your Browserbase Project ID"
51- )
48+ session = stagehand.sessions.start
5249rescue Stagehand ::Errors ::APIConnectionError => e
5350 puts (" The server could not be reached" )
5451 puts (e.cause) # an underlying Exception, likely raised within `net/http`
@@ -91,11 +88,7 @@ stagehand = Stagehand::Client.new(
9188)
9289
9390# Or, configure per-request:
94- stagehand.sessions.start(
95- browserbase_api_key: " your Browserbase API key" ,
96- browserbase_project_id: " your Browserbase Project ID" ,
97- request_options: {max_retries: 5 }
98- )
91+ stagehand.sessions.start(request_options: {max_retries: 5 })
9992```
10093
10194### Timeouts
@@ -109,11 +102,7 @@ stagehand = Stagehand::Client.new(
109102)
110103
111104# Or, configure per-request:
112- stagehand.sessions.start(
113- browserbase_api_key: " your Browserbase API key" ,
114- browserbase_project_id: " your Browserbase Project ID" ,
115- request_options: {timeout: 5 }
116- )
105+ stagehand.sessions.start(request_options: {timeout: 5 })
117106```
118107
119108On timeout, ` Stagehand::Errors::APITimeoutError ` is raised.
@@ -145,8 +134,6 @@ Note: the `extra_` parameters of the same name overrides the documented paramete
145134``` ruby
146135response =
147136 stagehand.sessions.start(
148- browserbase_api_key: " your Browserbase API key" ,
149- browserbase_project_id: " your Browserbase Project ID" ,
150137 request_options: {
151138 extra_query: {my_query_parameter: value},
152139 extra_body: {my_body_parameter: value},
@@ -192,46 +179,18 @@ This library provides comprehensive [RBI](https://sorbet.org/docs/rbi) definitio
192179You can provide typesafe request parameters like so:
193180
194181``` ruby
195- stagehand.sessions.act( " 00000000-your-session-id-000000000000 " , input: " click the first link on the page " )
182+ stagehand.sessions.start
196183```
197184
198185Or, equivalently:
199186
200187``` ruby
201188# Hashes work, but are not typesafe:
202- stagehand.sessions.act( " 00000000-your-session-id-000000000000 " , input: " click the first link on the page " )
189+ stagehand.sessions.start
203190
204191# You can also splat a full Params class:
205- params = Stagehand ::SessionActParams .new (input: " click the first link on the page" )
206- stagehand.sessions.act(" 00000000-your-session-id-000000000000" , ** params)
207- ```
208-
209- ### Enums
210-
211- Since this library does not depend on ` sorbet-runtime ` , it cannot provide [ ` T::Enum ` ] ( https://sorbet.org/docs/tenum ) instances. Instead, we provide "tagged symbols" instead, which is always a primitive at runtime:
212-
213- ``` ruby
214- # :true
215- puts (Stagehand ::SessionActParams ::XStreamResponse ::TRUE )
216-
217- # Revealed type: `T.all(Stagehand::SessionActParams::XStreamResponse, Symbol)`
218- T .reveal_type(Stagehand ::SessionActParams ::XStreamResponse ::TRUE )
219- ```
220-
221- Enum parameters have a "relaxed" type, so you can either pass in enum constants or their literal value:
222-
223- ``` ruby
224- # Using the enum constants preserves the tagged type information:
225- stagehand.sessions.act(
226- x_stream_response: Stagehand ::SessionActParams ::XStreamResponse ::TRUE ,
227- # …
228- )
229-
230- # Literal values are also permissible:
231- stagehand.sessions.act(
232- x_stream_response: :true ,
233- # …
234- )
192+ params = Stagehand ::SessionStartParams .new
193+ stagehand.sessions.start(** params)
235194```
236195
237196## Versioning
0 commit comments