Class: LittleGhost::StreamEvent

Inherits:
Data
  • Object
show all
Defined in:
lib/little_ghost/stream_event.rb,
lib/little_ghost/stream_event.rb

Overview

StreamEvent gives every provider and interface the same language for live agent output. Consumers can handle text, reasoning, tools, usage, retries, and completion without branching on a provider SDK.

Providers emit events such as :message_start, :text_delta, :reasoning_delta, :tool_call_start, :tool_call_delta, :tool_call_stop, :usage, :model_retry, and :message_stop. The terminal event carries a ModelResponse in data[:response]. An :agent_stream event wraps a copied, frozen Agent event with an AgentStreamSource when a Run exposes nested work.

event = LittleGhost::StreamEvent.build(:text_delta, text: "Hello")
event.type        # => :text_delta
event.data[:text] # => "Hello"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data

Returns:

  • (Object)

    the current value of data



4
5
6
# File 'lib/little_ghost/stream_event.rb', line 4

def data
  @data
end

#typeObject (readonly)

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



4
5
6
# File 'lib/little_ghost/stream_event.rb', line 4

def type
  @type
end

Class Method Details

.build(type, **data) ⇒ Object

Creates an event with a symbol type and frozen outer payload Hash.



6
7
8
# File 'lib/little_ghost/stream_event.rb', line 6

def self.build(type, **data)
  new(type: type.to_sym, data: data.freeze)
end