controllers/session.rb in nano-bots-0.0.7 vs controllers/session.rb in nano-bots-0.0.8

- old
+ new

@@ -59,10 +59,12 @@ def evaluate_and_print(message, mode:) behavior = Logic::Helpers::Hash.fetch(@cartridge, %i[behaviors interaction]) || {} @state[:history] << { who: 'user', + mode: mode.to_s, + input: message, message: Components::Adapter.apply( :input, Logic::Cartridge::Interaction.input(@cartridge, mode.to_sym, message) ) } @@ -70,10 +72,13 @@ process(input, mode:) end def process(input, mode:) + prefix = Logic::Cartridge::Affixes.get(@cartridge, mode.to_sym, :output, :prefix) + suffix = Logic::Cartridge::Affixes.get(@cartridge, mode.to_sym, :output, :suffix) + interface = Logic::Helpers::Hash.fetch(@cartridge, [:interfaces, mode.to_sym]) || {} streaming = Logic::Cartridge::Streaming.enabled?(@cartridge, mode.to_sym) input[:interface] = interface @@ -83,16 +88,21 @@ ready = false @provider.evaluate(input) do |output, finished| updated_at = Time.now if finished - @state[:history] << Marshal.load(Marshal.dump(output)) + event = Marshal.load(Marshal.dump(output)) output = Logic::Cartridge::Interaction.output( @cartridge, mode.to_sym, output, streaming, finished ) output[:message] = Components::Adapter.apply(:output, output[:message]) + + event[:mode] = mode.to_s + event[:output] = "#{prefix}#{output[:message]}#{suffix}" + + @state[:history] << event self.print(output[:message]) unless streaming ready = true flush