Class: RubyLLM::MCP::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_llm/mcp/task.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(adapter, task_response) ⇒ Task

Returns a new instance of Task.



9
10
11
12
13
14
15
16
17
18
# File 'lib/ruby_llm/mcp/task.rb', line 9

def initialize(adapter, task_response)
  @adapter = adapter
  @task_id = task_response["taskId"]
  @status = task_response["status"]
  @status_message = task_response["statusMessage"]
  @created_at = task_response["createdAt"]
  @last_updated_at = task_response["lastUpdatedAt"]
  @ttl = task_response["ttl"]
  @poll_interval = task_response["pollInterval"]
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



6
7
8
# File 'lib/ruby_llm/mcp/task.rb', line 6

def adapter
  @adapter
end

#created_atObject (readonly)

Returns the value of attribute created_at.



6
7
8
# File 'lib/ruby_llm/mcp/task.rb', line 6

def created_at
  @created_at
end

#last_updated_atObject (readonly)

Returns the value of attribute last_updated_at.



6
7
8
# File 'lib/ruby_llm/mcp/task.rb', line 6

def last_updated_at
  @last_updated_at
end

#poll_intervalObject (readonly)

Returns the value of attribute poll_interval.



6
7
8
# File 'lib/ruby_llm/mcp/task.rb', line 6

def poll_interval
  @poll_interval
end

#statusObject (readonly)

Returns the value of attribute status.



6
7
8
# File 'lib/ruby_llm/mcp/task.rb', line 6

def status
  @status
end

#status_messageObject (readonly)

Returns the value of attribute status_message.



6
7
8
# File 'lib/ruby_llm/mcp/task.rb', line 6

def status_message
  @status_message
end

#task_idObject (readonly)

Returns the value of attribute task_id.



6
7
8
# File 'lib/ruby_llm/mcp/task.rb', line 6

def task_id
  @task_id
end

#ttlObject (readonly)

Returns the value of attribute ttl.



6
7
8
# File 'lib/ruby_llm/mcp/task.rb', line 6

def ttl
  @ttl
end

Instance Method Details

#cancelObject



44
45
46
# File 'lib/ruby_llm/mcp/task.rb', line 44

def cancel
  self.class.new(@adapter, @adapter.task_cancel(task_id: task_id).value)
end

#cancelled?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/ruby_llm/mcp/task.rb', line 36

def cancelled?
  status == "cancelled"
end

#completed?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/ruby_llm/mcp/task.rb', line 28

def completed?
  status == "completed"
end

#failed?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/ruby_llm/mcp/task.rb', line 32

def failed?
  status == "failed"
end

#input_required?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/ruby_llm/mcp/task.rb', line 24

def input_required?
  status == "input_required"
end

#refreshObject



48
49
50
# File 'lib/ruby_llm/mcp/task.rb', line 48

def refresh
  self.class.new(@adapter, @adapter.task_get(task_id: task_id).value)
end

#resultObject



40
41
42
# File 'lib/ruby_llm/mcp/task.rb', line 40

def result
  @adapter.task_result(task_id: task_id).value
end

#to_hObject



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/ruby_llm/mcp/task.rb', line 52

def to_h
  {
    task_id: task_id,
    status: status,
    status_message: status_message,
    created_at: created_at,
    last_updated_at: last_updated_at,
    ttl: ttl,
    poll_interval: poll_interval
  }
end

#working?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/ruby_llm/mcp/task.rb', line 20

def working?
  status == "working"
end