Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.4.0"
".": "0.5.0"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 7
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-f7d6b6489159f611a2bfdc267ce0a6fc0455bed1ffa0c310044baaa5d8381b9b.yml
openapi_spec_hash: cd88d8068abfde8382da0bed674e440c
config_hash: 5c69fb596588b8ace08203858518c149
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-ed52466945f2f8dfd3814a29e948d7bf30af7b76a7a7689079c03b8baf64e26f.yml
openapi_spec_hash: 5d57aaf2362b0d882372dbf76477ba23
config_hash: 989ddfee371586e9156b4d484ec0a6cc
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## 0.5.0 (2025-12-23)

Full Changelog: [v0.4.0...v0.5.0](https://github.com/browserbase/stagehand-ruby/compare/v0.4.0...v0.5.0)

### Features

* [STG-1053] [server] Use fastify-zod-openapi + zod v4 for openapi generation ([926a819](https://github.com/browserbase/stagehand-ruby/commit/926a819a4bbe2b260d3dbd46b860c444f60857bf))
* **api:** manual updates ([0619302](https://github.com/browserbase/stagehand-ruby/commit/061930217b3efce30e29cf8b2511970b21c86c57))


### Documentation

* add more examples ([3e81eba](https://github.com/browserbase/stagehand-ruby/commit/3e81eba0b962a3ec0c9a8b13fc9ae30f0961663e))

## 0.4.0 (2025-12-19)

Full Changelog: [v0.3.0...v0.4.0](https://github.com/browserbase/stagehand-ruby/compare/v0.3.0...v0.4.0)
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GIT
PATH
remote: .
specs:
stagehand (0.4.0)
stagehand (0.5.0)
connection_pool

GEM
Expand Down
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ To use this gem, install via Bundler by adding the following to your application
<!-- x-release-please-start-version -->

```ruby
gem "stagehand", "~> 0.4.0"
gem "stagehand", "~> 0.5.0"
```

<!-- x-release-please-end -->
Expand All @@ -39,6 +39,21 @@ response = stagehand.sessions.act("00000000-your-session-id-000000000000", input
puts(response.data)
```

### Streaming

We provide support for streaming responses using Server-Sent Events (SSE).

```ruby
stream = stagehand.sessions.act_streaming(
"00000000-your-session-id-000000000000",
input: "click the first link on the page"
)

stream.each do |session|
puts(session.data)
end
```

### Handling errors

When the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `Stagehand::Errors::APIError` will be thrown:
Expand Down
10 changes: 9 additions & 1 deletion lib/stagehand/models/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,19 @@ class Action < Stagehand::Internal::Type::BaseModel
# @return [Array<String>, nil]
optional :arguments, Stagehand::Internal::Type::ArrayOf[String]

# @!attribute backend_node_id
# Backend node ID for the element
#
# @return [Float, nil]
optional :backend_node_id, Float, api_name: :backendNodeId

# @!attribute method_
# The method to execute (click, fill, etc.)
#
# @return [String, nil]
optional :method_, String, api_name: :method

# @!method initialize(description:, selector:, arguments: nil, method_: nil)
# @!method initialize(description:, selector:, arguments: nil, backend_node_id: nil, method_: nil)
# Action object returned by observe and used by act
#
# @param description [String] Human-readable description of the action
Expand All @@ -36,6 +42,8 @@ class Action < Stagehand::Internal::Type::BaseModel
#
# @param arguments [Array<String>] Arguments to pass to the method
#
# @param backend_node_id [Float] Backend node ID for the element
#
# @param method_ [String] The method to execute (click, fill, etc.)
end
end
Expand Down
25 changes: 24 additions & 1 deletion lib/stagehand/models/model_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,35 @@ class ModelConfigObject < Stagehand::Internal::Type::BaseModel
# @return [String, nil]
optional :base_url, String, api_name: :baseURL

# @!method initialize(model_name:, api_key: nil, base_url: nil)
# @!attribute provider
# AI provider for the model (or provide a baseURL endpoint instead)
#
# @return [Symbol, Stagehand::Models::ModelConfig::ModelConfigObject::Provider, nil]
optional :provider, enum: -> { Stagehand::ModelConfig::ModelConfigObject::Provider }

# @!method initialize(model_name:, api_key: nil, base_url: nil, provider: nil)
# @param model_name [String] Model name string without prefix (e.g., 'gpt-5-nano', 'claude-4.5-opus')
#
# @param api_key [String] API key for the model provider
#
# @param base_url [String] Base URL for the model provider
#
# @param provider [Symbol, Stagehand::Models::ModelConfig::ModelConfigObject::Provider] AI provider for the model (or provide a baseURL endpoint instead)

# AI provider for the model (or provide a baseURL endpoint instead)
#
# @see Stagehand::Models::ModelConfig::ModelConfigObject#provider
module Provider
extend Stagehand::Internal::Type::Enum

OPENAI = :openai
ANTHROPIC = :anthropic
GOOGLE = :google
MICROSOFT = :microsoft

# @!method self.values
# @return [Array<Symbol>]
end
end

# @!method self.variants
Expand Down
52 changes: 49 additions & 3 deletions lib/stagehand/models/session_act_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ class Result < Stagehand::Internal::Type::BaseModel
# @!attribute actions
# List of actions that were executed
#
# @return [Array<Stagehand::Models::Action>]
required :actions, -> { Stagehand::Internal::Type::ArrayOf[Stagehand::Action] }
# @return [Array<Stagehand::Models::SessionActResponse::Data::Result::Action>]
required :actions,
-> { Stagehand::Internal::Type::ArrayOf[Stagehand::Models::SessionActResponse::Data::Result::Action] }

# @!attribute message
# Human-readable result message
Expand All @@ -69,11 +70,56 @@ class Result < Stagehand::Internal::Type::BaseModel
# @!method initialize(action_description:, actions:, message:, success:)
# @param action_description [String] Description of the action that was performed
#
# @param actions [Array<Stagehand::Models::Action>] List of actions that were executed
# @param actions [Array<Stagehand::Models::SessionActResponse::Data::Result::Action>] List of actions that were executed
#
# @param message [String] Human-readable result message
#
# @param success [Boolean] Whether the action completed successfully

class Action < Stagehand::Internal::Type::BaseModel
# @!attribute description
# Human-readable description of the action
#
# @return [String]
required :description, String

# @!attribute selector
# CSS selector or XPath for the element
#
# @return [String]
required :selector, String

# @!attribute arguments
# Arguments to pass to the method
#
# @return [Array<String>, nil]
optional :arguments, Stagehand::Internal::Type::ArrayOf[String]

# @!attribute backend_node_id
# Backend node ID for the element
#
# @return [Float, nil]
optional :backend_node_id, Float, api_name: :backendNodeId

# @!attribute method_
# The method to execute (click, fill, etc.)
#
# @return [String, nil]
optional :method_, String, api_name: :method

# @!method initialize(description:, selector:, arguments: nil, backend_node_id: nil, method_: nil)
# Action object returned by observe and used by act
#
# @param description [String] Human-readable description of the action
#
# @param selector [String] CSS selector or XPath for the element
#
# @param arguments [Array<String>] Arguments to pass to the method
#
# @param backend_node_id [Float] Backend node ID for the element
#
# @param method_ [String] The method to execute (click, fill, etc.)
end
end
end
end
Expand Down
25 changes: 24 additions & 1 deletion lib/stagehand/models/session_execute_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,44 @@ class AgentConfig < Stagehand::Internal::Type::BaseModel
# @return [String, Stagehand::Models::ModelConfig::ModelConfigObject, nil]
optional :model, union: -> { Stagehand::ModelConfig }

# @!attribute provider
# AI provider for the agent (legacy, use model: openai/gpt-5-nano instead)
#
# @return [Symbol, Stagehand::Models::SessionExecuteParams::AgentConfig::Provider, nil]
optional :provider, enum: -> { Stagehand::SessionExecuteParams::AgentConfig::Provider }

# @!attribute system_prompt
# Custom system prompt for the agent
#
# @return [String, nil]
optional :system_prompt, String, api_name: :systemPrompt

# @!method initialize(cua: nil, model: nil, system_prompt: nil)
# @!method initialize(cua: nil, model: nil, provider: nil, system_prompt: nil)
# Some parameter documentations has been truncated, see
# {Stagehand::Models::SessionExecuteParams::AgentConfig} for more details.
#
# @param cua [Boolean] Enable Computer Use Agent mode
#
# @param model [String, Stagehand::Models::ModelConfig::ModelConfigObject] Model name string with provider prefix (e.g., 'openai/gpt-5-nano', 'anthropic/cl
#
# @param provider [Symbol, Stagehand::Models::SessionExecuteParams::AgentConfig::Provider] AI provider for the agent (legacy, use model: openai/gpt-5-nano instead)
#
# @param system_prompt [String] Custom system prompt for the agent

# AI provider for the agent (legacy, use model: openai/gpt-5-nano instead)
#
# @see Stagehand::Models::SessionExecuteParams::AgentConfig#provider
module Provider
extend Stagehand::Internal::Type::Enum

OPENAI = :openai
ANTHROPIC = :anthropic
GOOGLE = :google
MICROSOFT = :microsoft

# @!method self.values
# @return [Array<Symbol>]
end
end

class ExecuteOptions < Stagehand::Internal::Type::BaseModel
Expand Down
52 changes: 49 additions & 3 deletions lib/stagehand/models/session_observe_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ class SessionObserveResponse < Stagehand::Internal::Type::BaseModel
class Data < Stagehand::Internal::Type::BaseModel
# @!attribute result
#
# @return [Array<Stagehand::Models::Action>]
required :result, -> { Stagehand::Internal::Type::ArrayOf[Stagehand::Action] }
# @return [Array<Stagehand::Models::SessionObserveResponse::Data::Result>]
required :result,
-> { Stagehand::Internal::Type::ArrayOf[Stagehand::Models::SessionObserveResponse::Data::Result] }

# @!attribute action_id
# Action ID for tracking
Expand All @@ -36,9 +37,54 @@ class Data < Stagehand::Internal::Type::BaseModel
optional :action_id, String, api_name: :actionId

# @!method initialize(result:, action_id: nil)
# @param result [Array<Stagehand::Models::Action>]
# @param result [Array<Stagehand::Models::SessionObserveResponse::Data::Result>]
#
# @param action_id [String] Action ID for tracking

class Result < Stagehand::Internal::Type::BaseModel
# @!attribute description
# Human-readable description of the action
#
# @return [String]
required :description, String

# @!attribute selector
# CSS selector or XPath for the element
#
# @return [String]
required :selector, String

# @!attribute arguments
# Arguments to pass to the method
#
# @return [Array<String>, nil]
optional :arguments, Stagehand::Internal::Type::ArrayOf[String]

# @!attribute backend_node_id
# Backend node ID for the element
#
# @return [Float, nil]
optional :backend_node_id, Float, api_name: :backendNodeId

# @!attribute method_
# The method to execute (click, fill, etc.)
#
# @return [String, nil]
optional :method_, String, api_name: :method

# @!method initialize(description:, selector:, arguments: nil, backend_node_id: nil, method_: nil)
# Action object returned by observe and used by act
#
# @param description [String] Human-readable description of the action
#
# @param selector [String] CSS selector or XPath for the element
#
# @param arguments [Array<String>] Arguments to pass to the method
#
# @param backend_node_id [Float] Backend node ID for the element
#
# @param method_ [String] The method to execute (click, fill, etc.)
end
end
end
end
Expand Down
Loading
Loading