class RubyLLM::Browser::Session

A live browser session handle.

A session exposes only what policy and provenance need: an id, the current (possibly redirected) URL and a start time. It deliberately has no reader for the provider’s ‘cdp_url`: that is a full-control DevTools endpoint and must never reach a tool result, model message or log.

Attributes

id[R]
started_at[R]
url[R]

Public Class Methods

new(id:, url: nil, started_at: nil) click to toggle source
# File lib/ruby_llm/browser/backend.rb, line 14
def initialize(id:, url: nil, started_at: nil)
  raise InvalidInput, "session id must be a non-empty String" unless id.is_a?(String) && !id.empty?

  @id = id
  @url = url
  @started_at = started_at
  freeze
end

Public Instance Methods

inspect(= " click to toggle source
# File lib/ruby_llm/browser/backend.rb, line 32
  def inspect = "#<#{self.class} id=#{id} url=#{url.inspect}>"
end
to_h() click to toggle source
# File lib/ruby_llm/browser/backend.rb, line 28
def to_h
  { id: id, url: url, started_at: started_at&.utc&.iso8601 }
end
with_url(url) click to toggle source

Returns a copy with a new current URL.

# File lib/ruby_llm/browser/backend.rb, line 24
def with_url(url)
  self.class.new(id: id, url: url, started_at: started_at)
end