module RubyLLM::Browser::Rails

Durable, multi-worker adapter for hosts that run Rails (or plain ActiveRecord + Active Job). It provides an ActiveRecord operation/approval store, a scoped Active Job, and a cleanup reaper. It never guesses provider truth and never starts a session the core would refuse.

Attributes

approval_store[W]
clock[W]
context_factory[RW]

->(actor_id:, run_id:) { RubyLLM::Browser::Context }, supplied by the host.

job_queue[W]
operation_store[W]
result_delivery[R]

Optional host callback: ->(operation:, result:) { persist_result }. Runs synchronously after execution and cleanup, before the job returns. Raise to report failure; return values are ignored. Duplicate jobs do not redeliver. The host owns persistence, idempotency, access and recovery.

Public Class Methods

approval_store() click to toggle source

Durable approval store. Defaults to an {ActiveRecordApprovalStore}.

# File lib/ruby_llm/browser/rails.rb, line 78
def approval_store
  @approval_store ||= ActiveRecordApprovalStore.new
end
clock() click to toggle source

Returns the current UTC time used by the adapter.

# File lib/ruby_llm/browser/rails.rb, line 60
def clock
  @clock ||= -> { Time.now.utc }
end
job_queue() click to toggle source

The Active Job queue name. Defaults to ‘:default`.

# File lib/ruby_llm/browser/rails.rb, line 66
def job_queue
  @job_queue || :default
end
operation_store() click to toggle source

Durable operation store. Defaults to an {ActiveRecordOperationStore}.

# File lib/ruby_llm/browser/rails.rb, line 72
def operation_store
  @operation_store ||= ActiveRecordOperationStore.new
end
reset!() click to toggle source

Restores process defaults. Primarily a test helper.

# File lib/ruby_llm/browser/rails.rb, line 84
def reset!
  @context_factory = nil
  @result_delivery = nil
  @clock = nil
  @job_queue = nil
  @operation_store = nil
  @approval_store = nil
end
result_delivery=(callback) click to toggle source
# File lib/ruby_llm/browser/rails.rb, line 51
def result_delivery=(callback)
  unless callback.nil? || callback.respond_to?(:call)
    raise InvalidInput, "result_delivery must be callable or nil"
  end

  @result_delivery = callback
end