Class: SwarmSDK::Tools::Stores::TodoManager

Inherits:
Object
  • Object
show all
Defined in:
lib/swarm_sdk/tools/stores/todo_manager.rb

Overview

TodoManager provides per-agent todo list storage

Each agent maintains its own independent todo list that persists throughout the agent's execution session. This allows agents to track progress on complex multi-step tasks.

Class Method Summary collapse

Class Method Details

.clear_allObject

Clear all todos for all agents



47
48
49
50
51
# File 'lib/swarm_sdk/tools/stores/todo_manager.rb', line 47

def clear_all
  @mutex.synchronize do
    @storage.clear
  end
end

.clear_todos(agent_id) ⇒ Object

Clear all todos for an agent

Parameters:

  • agent_id (Symbol, String)

    Unique agent identifier



40
41
42
43
44
# File 'lib/swarm_sdk/tools/stores/todo_manager.rb', line 40

def clear_todos(agent_id)
  @mutex.synchronize do
    @storage.delete(agent_id.to_sym)
  end
end

.get_todos(agent_id) ⇒ Array<Hash>

Get the current todo list for an agent

Parameters:

  • agent_id (Symbol, String)

    Unique agent identifier

Returns:

  • (Array<Hash>)

    Array of todo items



20
21
22
23
24
# File 'lib/swarm_sdk/tools/stores/todo_manager.rb', line 20

def get_todos(agent_id)
  @mutex.synchronize do
    @storage[agent_id.to_sym] ||= []
  end
end

.set_todos(agent_id, todos) ⇒ Array<Hash>

Set the todo list for an agent

Parameters:

  • agent_id (Symbol, String)

    Unique agent identifier

  • todos (Array<Hash>)

    Array of todo items

Returns:

  • (Array<Hash>)

    The stored todos



31
32
33
34
35
# File 'lib/swarm_sdk/tools/stores/todo_manager.rb', line 31

def set_todos(agent_id, todos)
  @mutex.synchronize do
    @storage[agent_id.to_sym] = todos
  end
end

.summaryHash

Get summary of all agent todo lists

Returns:

  • (Hash)

    Map of agent_id => todo count



56
57
58
59
60
# File 'lib/swarm_sdk/tools/stores/todo_manager.rb', line 56

def summary
  @mutex.synchronize do
    @storage.transform_values(&:size)
  end
end