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
->(actor_id:, run_id:) { RubyLLM::Browser::Context }, supplied by the host.
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
Durable approval store. Defaults to an {ActiveRecordApprovalStore}.
# File lib/ruby_llm/browser/rails.rb, line 78 def approval_store @approval_store ||= ActiveRecordApprovalStore.new end
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
The Active Job queue name. Defaults to ‘:default`.
# File lib/ruby_llm/browser/rails.rb, line 66 def job_queue @job_queue || :default end
Durable operation store. Defaults to an {ActiveRecordOperationStore}.
# File lib/ruby_llm/browser/rails.rb, line 72 def operation_store @operation_store ||= ActiveRecordOperationStore.new end
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
# 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