Read-only by default
Inspect and Extract do not dispatch browser actions, and page content remains untrusted evidence.
Inspect and extract
An unofficial RubyLLM extension for bounded browser inspection and schema-checked extraction through the Stagehand Ruby SDK.
This gem has not been published to RubyGems. Install the unreleased source from GitHub.
A version such as 0.1.0 in the source tree is not a claim that a public release exists.
bundle add ruby_llm-browser --git https://github.com/yorzi/ruby_llm-browser --branch main
This offline example makes no network request and needs no API key.
require "ruby_llm/browser"
class OfflineResolver
def getaddresses(_host) = [ "93.184.216.34" ]
end
context = RubyLLM::Browser::Context.new(
actor_id: "demo-actor", run_id: "demo-run",
backend: RubyLLM::Browser::FakeBackend.new,
source_policy: RubyLLM::Browser::Policy.new(
allowed_hosts: [ "docs.example.com" ], resolver: OfflineResolver.new
),
operation_store: RubyLLM::Browser::InMemoryOperationStore.new
)
schema = {
"type" => "object",
"properties" => { "title" => { "type" => "string" } },
"required" => [ "title" ], "additionalProperties" => false
}
inspect_tool = RubyLLM::Browser::Inspect.new(context: context)
extract_tool = RubyLLM::Browser::Extract.new(context: context, schema: schema)
puts inspect_tool.execute(url: "https://docs.example.com/")[:status] # => ok
puts extract_tool.execute(url: "https://docs.example.com/")[:data] # => {"title"=>"Example"}
The fake backend proves only that the Ruby API can run offline. It says nothing about a real browser provider’s egress, session cleanup, or billing. Read the security model before evaluating a live backend.
Get started or read how the gem works.