Class: A2A::Streaming::StatusUpdateEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/a2a/streaming/status_update_event.rb

Overview

The ‘final` field is a gem-level streaming-termination hint, not in the A2A proto. Servers that set “final”: true signal this is the last status event for the task.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context_id:, task_id:, status:, **kwargs) ⇒ StatusUpdateEvent

Returns a new instance of StatusUpdateEvent.

Raises:

  • (TypeError)


10
11
12
13
14
15
16
17
18
# File 'lib/a2a/streaming/status_update_event.rb', line 10

def initialize(context_id:, task_id:, status:, **kwargs)
  raise TypeError, "status must be a Task::Status" unless status.is_a?(Task::Status)

  @context_id = context_id
  @task_id = task_id
  @status = status
  @final = kwargs.fetch(:final, false)
  @metadata = kwargs[:metadata]
end

Instance Attribute Details

#context_idObject (readonly)

Returns the value of attribute context_id.



8
9
10
# File 'lib/a2a/streaming/status_update_event.rb', line 8

def context_id
  @context_id
end

#finalObject (readonly)

Returns the value of attribute final.



8
9
10
# File 'lib/a2a/streaming/status_update_event.rb', line 8

def final
  @final
end

#metadataObject (readonly)

Returns the value of attribute metadata.



8
9
10
# File 'lib/a2a/streaming/status_update_event.rb', line 8

def 
  @metadata
end

#statusObject (readonly)

Returns the value of attribute status.



8
9
10
# File 'lib/a2a/streaming/status_update_event.rb', line 8

def status
  @status
end

#task_idObject (readonly)

Returns the value of attribute task_id.



8
9
10
# File 'lib/a2a/streaming/status_update_event.rb', line 8

def task_id
  @task_id
end

Class Method Details

.from_h(hash) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/a2a/streaming/status_update_event.rb', line 32

def self.from_h(hash)
  new(
    task_id: hash.fetch("taskId"),
    context_id: hash.fetch("contextId"),
    status: Task::Status.from_h(hash.fetch("status")),
    final: hash.fetch("final", false),
    metadata: hash["metadata"]
  )
end

Instance Method Details

#final?Boolean

Returns:

  • (Boolean)


20
# File 'lib/a2a/streaming/status_update_event.rb', line 20

def final? = @final

#to_hObject



22
23
24
25
26
27
28
29
30
# File 'lib/a2a/streaming/status_update_event.rb', line 22

def to_h
  {
    "taskId" => task_id,
    "contextId" => context_id,
    "status" => status.to_h,
    "final" => final,
    "metadata" => 
  }.compact
end