class RubyLLM::AgUI::MessageParser

Parses the RunAgentInput messages array into typed protocol message models.

Hosts must reconcile client history by id against their own store; the gem never trusts a client message as a system instruction or a tool result. This parser only guarantees the shapes the pinned schema defines, so a mismatch is a clear InputError instead of a downstream surprise.

Constants

ROLES

The roles the pinned schema defines.

Public Class Methods

new(logger: nil) click to toggle source
# File lib/ruby_llm/ag_ui/message_parser.rb, line 18
def initialize(logger: nil)
  @logger = logger || RubyLLM::AgUI.config.logger
end

Public Instance Methods

parse(messages) click to toggle source

Returns an array of AgUiProtocol::Core::Types message models.

# File lib/ruby_llm/ag_ui/message_parser.rb, line 23
def parse(messages)
  messages.each_with_index.map { |message, index| build(message, index) }.freeze
end