class Riffer::Rig::Runtime::Snapshot
Attributes
id
[R]
String
@dynamic id, messages, model, reasoning, skills
messages
[R]
Array[Riffer::Messages::Base]
model
[R]
String?
reasoning
[R]
String?
skills
[R]
Array[String]
Public Class Methods
(Hash[Symbol, untyped] hash) → Riffer::Rig::Runtime::Snapshot
Source
# File lib/riffer/rig/runtime/snapshot.rb, line 21 def self.from_h(hash) new( id: hash.fetch(:id), # Upstream candidate: riffer's Serializer carries an agent's config, never # its history, so this and to_h round-trip the session message by message; # a Session.from_h could also heal orphaned tool calls on load. messages: hash.fetch(:messages).map { |stored| message(stored) }, model: hash.fetch(:model), reasoning: hash[:reasoning].is_a?(String) ? hash[:reasoning] : nil, skills: hash.fetch(:skills) ) end
@rbs hash: Hash[Symbol, untyped] @rbs return: Riffer::Rig::Runtime::Snapshot
(Hash[Symbol, untyped] hash) → Riffer::Messages::Base
Source
# File lib/riffer/rig/runtime/snapshot.rb, line 36 def self.message(hash) # riffer rebuilds a message from its role alone, which would bring a job # notification back as typed input. return Riffer::Rig::Runtime::JobNotification.from_hash(hash) if hash[Riffer::Rig::Runtime::JobNotification::MARKER] Riffer::Messages::Base.from_hash(hash) end
@rbs hash: Hash[Symbol, untyped] @rbs return: Riffer::Messages::Base
(id: String, messages: Array[Riffer::Messages::Base], model: String?, skills: Array[String], ?reasoning: String?) → void
Source
# File lib/riffer/rig/runtime/snapshot.rb, line 50 def initialize(id:, messages:, model:, skills:, reasoning: nil) @id = id @messages = messages @model = model @reasoning = reasoning @skills = skills freeze end
(Riffer::Rig::Runtime::Snapshot | Hash[Symbol, untyped] snapshot) → Riffer::Rig::Runtime::Snapshot
Source
# File lib/riffer/rig/runtime/snapshot.rb, line 15 def self.of(snapshot) snapshot.is_a?(Riffer::Rig::Runtime::Snapshot) ? snapshot : from_h(snapshot) end
@rbs snapshot: Riffer::Rig::Runtime::Snapshot | Hash[Symbol, untyped] @rbs return: Riffer::Rig::Runtime::Snapshot
Public Instance Methods
(Hash[Symbol, Hash[Symbol, String]] credentials, Riffer::Rig::Hosts::_Host host, String fallback) → String?
Source
# File lib/riffer/rig/runtime/snapshot.rb, line 92 def restorable_model(credentials, host, fallback) saved = @model return nil unless saved provider = saved.split('/', 2).first.to_s return saved if credentials.key?(provider.to_sym) host.notify("Not restoring model #{saved}: #{provider} has no credentials; using #{fallback}", level: :warning) nil end
@rbs credentials: Hash[Symbol, Hash[Symbol, String]] @rbs host: Riffer::Rig::Hosts::_Host @rbs fallback: String @rbs return: String?
() → Riffer::Agent::Session
Source
# File lib/riffer/rig/runtime/snapshot.rb, line 75 def session # riffer's Session appends to the array it is given. session = Riffer::Agent::Session.new(messages: @messages.dup) session.discard_pending_tool_calls session end
@rbs return: Riffer::Agent::Session
() → Hash[Symbol, untyped]
Source
# File lib/riffer/rig/runtime/snapshot.rb, line 60 def to_h { id: @id, messages: @messages.map(&:to_h), model: @model, reasoning: @reasoning, skills: @skills } end
@rbs return: Hash[Symbol, untyped]
() → Riffer::Providers::TokenUsage?
Source
# File lib/riffer/rig/runtime/snapshot.rb, line 83 def usage # Upstream candidate: a loaded session could restore its own tally. Riffer::Rig::Runtime::Usage.sum(@messages) end
@rbs return: Riffer::Providers::TokenUsage?
Source
# File lib/riffer/rig/runtime/snapshot.rb, line 65 def without_model self.class.new(id: @id, messages: @messages, model: nil, reasoning: @reasoning, skills: @skills) end
@rbs return: Riffer::Rig::Runtime::Snapshot
Source
# File lib/riffer/rig/runtime/snapshot.rb, line 70 def without_reasoning self.class.new(id: @id, messages: @messages, model: @model, reasoning: nil, skills: @skills) end
@rbs return: Riffer::Rig::Runtime::Snapshot