Getting Started
Install the gem and run a read-only operation with its offline backend.
After reading this guide, you will know:
- How to install the published gem or the current source version.
- How to run Inspect and Extract without a provider or network request.
- Where to review live-provider limitations.
Installation
The stable release is 0.1.0. Add it to your Gemfile:
gem "ruby_llm-browser", "~> 0.1.0"
For unreleased development changes, install the default branch instead:
bundle add ruby_llm-browser --git https://github.com/yorzi/ruby_llm-browser --branch main
Use Ruby 3.2 or later. The gem supports RubyLLM >= 2.0, < 3 and pins Stagehand to the
3.21.x series. Rails is optional and is not loaded by the core entry point. See
configuration for host-owned settings.
Run a Read-only Operation Offline
This complete example needs no credentials and makes no network request. Its resolver returns a public test address so URL policy can be exercised without DNS.
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"}
FakeBackend supplies deterministic responses. The built-in Stagehand adapter is not
supported for live operations in this release. Use a custom backend only after you have
reviewed the security boundaries.
Next Steps
- How RubyLLM::Browser Works - follow the objects through an operation.
- Configuration - set process defaults and build a trusted context.
- Inspecting and extracting - register tools and interpret their results.