Class: A2A::Types::TaskStatusUpdateEvent

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/a2a/types/events.rb

Overview

Represents a task status update event

These events are sent when a task's status changes, allowing clients to track task progress in real-time.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#==, #camelize, from_h, from_json, #hash, #to_h, #to_json, underscore, #valid?, #validate_array_type, #validate_inclusion, #validate_required, #validate_type

Constructor Details

#initialize(task_id:, context_id:, status:, metadata: nil) ⇒ TaskStatusUpdateEvent

Initialize a new task status update event

Parameters:

  • The task identifier

  • The context identifier

  • The new task status

  • (defaults to: nil)

    Additional event metadata



21
22
23
24
25
26
27
28
# File 'lib/a2a/types/events.rb', line 21

def initialize(task_id:, context_id:, status:, metadata: nil)
  @task_id = task_id
  @context_id = context_id
  @status = status.is_a?(TaskStatus) ? status : TaskStatus.from_h(status)
   = 

  validate!
end

Instance Attribute Details

#context_idObject (readonly)

Returns the value of attribute context_id.



12
13
14
# File 'lib/a2a/types/events.rb', line 12

def context_id
  @context_id
end

#metadataObject (readonly)

Returns the value of attribute metadata.



12
13
14
# File 'lib/a2a/types/events.rb', line 12

def 
  
end

#statusObject (readonly)

Returns the value of attribute status.



12
13
14
# File 'lib/a2a/types/events.rb', line 12

def status
  @status
end

#task_idObject (readonly)

Returns the value of attribute task_id.



12
13
14
# File 'lib/a2a/types/events.rb', line 12

def task_id
  @task_id
end

Instance Method Details

#event_typeString

Get the event type

Returns:

  • The event type



34
35
36
# File 'lib/a2a/types/events.rb', line 34

def event_type
  "task_status_update"
end

#terminal?Boolean

Check if this is a terminal status update

Returns:

  • True if the status is terminal



42
43
44
# File 'lib/a2a/types/events.rb', line 42

def terminal?
  @status.state.in?(%w[completed canceled failed rejected])
end

#validate!Object (private)



48
49
50
51
52
53
# File 'lib/a2a/types/events.rb', line 48

def validate!
  validate_required(:task_id, :context_id, :status)
  validate_type(:task_id, String)
  validate_type(:context_id, String)
  validate_type(:status, TaskStatus)
end