Module: Xeno::Channels
- Defined in:
- lib/xeno/channels.rb,
lib/xeno/channels/slack.rb
Overview
The channel registry. A channel (a) normalizes platform input into user messages, (b) owns the session's continuation token, and (c) decides delivery of agent output. HTTP is built in; agent/channels/*.rb declare the rest via the DSL:
Xeno.channel :slack do
signing_secret Rails.application.credentials.dig(:slack, :signing_secret)
bot_token Rails.application.credentials.dig(:slack, :bot_token)
end
Delivery is a failable nicety: the durable truth lives in the transcript and event rows, so a failed post logs and moves on.
Defined Under Namespace
Classes: Slack
Class Method Summary collapse
- .build(name, &block) ⇒ Object
- .deliver_completion(session, content) ⇒ Object
- .deliver_input_request(session, actions) ⇒ Object
- .for_session(session) ⇒ Object
- .register(name, channel) ⇒ Object
- .registry ⇒ Object
-
.streamer_for(session) ⇒ Object
A per-reply delta sink (post-then-edit streaming) when the session's channel opts in; nil otherwise.
Class Method Details
.build(name, &block) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/xeno/channels.rb', line 25 def build(name, &block) case name.to_sym when :slack Slack.new(&block) else raise Xeno::Error, "unknown channel type: #{name} (v0.1 ships :slack; http is built in)" end end |
.deliver_completion(session, content) ⇒ Object
38 39 40 41 42 |
# File 'lib/xeno/channels.rb', line 38 def deliver_completion(session, content) for_session(session)&.deliver_completion(session, content) rescue StandardError => e Rails.logger.warn("xeno: channel delivery failed for session #{session.id}: #{e.class}: #{e.}") end |
.deliver_input_request(session, actions) ⇒ Object
44 45 46 47 48 |
# File 'lib/xeno/channels.rb', line 44 def deliver_input_request(session, actions) for_session(session)&.deliver_input_request(session, actions) rescue StandardError => e Rails.logger.warn("xeno: channel input-request delivery failed for session #{session.id}: #{e.class}: #{e.}") end |
.for_session(session) ⇒ Object
34 35 36 |
# File 'lib/xeno/channels.rb', line 34 def for_session(session) registry[session.channel&.to_sym] end |
.register(name, channel) ⇒ Object
21 22 23 |
# File 'lib/xeno/channels.rb', line 21 def register(name, channel) registry[name.to_sym] = channel end |
.registry ⇒ Object
17 18 19 |
# File 'lib/xeno/channels.rb', line 17 def registry @registry ||= {} end |
.streamer_for(session) ⇒ Object
A per-reply delta sink (post-then-edit streaming) when the session's channel opts in; nil otherwise. Failable nicety like all delivery.
52 53 54 55 56 57 58 59 60 |
# File 'lib/xeno/channels.rb', line 52 def streamer_for(session) channel = for_session(session) return nil unless channel.respond_to?(:streamer_for) channel.streamer_for(session) rescue StandardError => e Rails.logger.warn("xeno: channel streamer setup failed for session #{session.id}: #{e.class}: #{e.}") nil end |