class Riffer::Rig::ACP::Host
Constants
- BUILDING_CAPABILITIES
- CAPABILITIES
Attributes
::ACP::AgentConnection::Client
@dynamic client=
Public Class Methods
(client: ::ACP::AgentConnection::Client) → void
Source
# File lib/riffer/rig/acp/host.rb, line 22 def initialize(client:) @client = client @session_id = nil @buffered = [] @lock = Mutex.new end
@rbs client: ::ACP::AgentConnection::Client @rbs return: void
Public Instance Methods
(?String? question, ?options: Array[String]?, ?secret: bool) → String?
Source
# File lib/riffer/rig/acp/host.rb, line 40 def ask(question = nil, options: nil, secret: false) id = @session_id # ACP forbids asking for a secret in a form elicitation, and rig serves no # URL for the URL mode to open. return super unless id && !secret return elicit(id, question.to_s) unless options selected = permit(id, question.to_s, Riffer::Rig::ACP::Mapper.choices(options)) selected if options.include?(selected) end
@rbs question: String? @rbs options: Array? @rbs secret: bool @rbs return: String?
Riffer::Rig::Hosts::NonInteractive#ask
() → Set[Symbol]
Source
# File lib/riffer/rig/acp/host.rb, line 32 def capabilities @session_id ? CAPABILITIES : BUILDING_CAPABILITIES end
A request to the client names its session, so nothing can be relayed until the agent sets the id. @rbs return: Set
(?String? question) → bool
Source
# File lib/riffer/rig/acp/host.rb, line 53 def confirm(question = nil) id = @session_id return super unless id permit(id, question.to_s, Riffer::Rig::ACP::Mapper::CONFIRM_OPTIONS) == Riffer::Rig::ACP::Mapper::CONFIRMED end
@rbs question: String? @rbs return: bool
Riffer::Rig::Hosts::NonInteractive#confirm
(?String? message, ?level: Symbol) → void
Source
# File lib/riffer/rig/acp/host.rb, line 63 def notify(message = nil, level: :info) update(Riffer::Rig::ACP::Mapper.notice(message.to_s)) end
@rbs message: String? @rbs level: Symbol @rbs return: void
(?String? label) ?{ () → void } → void
Source
# File lib/riffer/rig/acp/host.rb, line 81 def progress(label = nil, &block) notify(label) if label block&.call end
@rbs label: String? @rbs &block: ? () -> void @rbs return: void
(String id) → void
Source
# File lib/riffer/rig/acp/host.rb, line 92 def session_id=(id) @lock.synchronize do @session_id = id @buffered.each { |update| @client.update(id, update) } @buffered = [] end end
Session updates name their session, and acp-sdk runs session_created after the session/new reply so the client knows the id before any update for it arrives โ that is why the build-time notifies wait for this, not for the Runtimeโs construction to end. @rbs id: String @rbs return: void
(::ACP::Types::SessionUpdate::t update) → void
Source
# File lib/riffer/rig/acp/host.rb, line 69 def update(update) # A job's exit reaches here on the job's own thread, racing session_id= for # the buffer. @lock.synchronize do id = @session_id id ? @client.update(id, update) : @buffered << update end end
@rbs update: ::ACP::Types::SessionUpdate::t @rbs return: void