Class: AgUiProtocol::Core::Events::RawEvent

Inherits:
BaseEvent show all
Defined in:
lib/ag_ui_protocol/core/events.rb

Overview

Used to pass through events from external systems.

“‘ruby event = AgUiProtocol::Core::Events::RawEvent.new(event: { “type” => “my_event”, “data” => { “a” => 1 } }, source: “my_source”) “`

Instance Attribute Summary collapse

Attributes inherited from BaseEvent

#raw_event, #timestamp, #type

Instance Method Summary collapse

Methods inherited from Types::Model

#as_json, #to_json

Constructor Details

#initialize(event:, source: nil, timestamp: nil, raw_event: nil) ⇒ RawEvent

Returns a new instance of RawEvent.



812
813
814
815
816
# File 'lib/ag_ui_protocol/core/events.rb', line 812

def initialize(event:, source: nil, timestamp: nil, raw_event: nil)
  super(type: EventType::RAW, timestamp: timestamp, raw_event: raw_event)
  @event = event
  @source = source
end

Instance Attribute Details

#eventObject (readonly)

Returns the value of attribute event.



802
803
804
# File 'lib/ag_ui_protocol/core/events.rb', line 802

def event
  @event
end

#sourceObject (readonly)

Returns the value of attribute source.



805
806
807
# File 'lib/ag_ui_protocol/core/events.rb', line 805

def source
  @source
end

Instance Method Details

#to_hObject



819
820
821
822
# File 'lib/ag_ui_protocol/core/events.rb', line 819

def to_h
  # `event` is the raw upstream event payload — preserve keys verbatim.
  super.merge(event: @event.nil? ? nil : AgUiProtocol::Util::Opaque.new(@event), source: @source)
end