Module: Legion::Extensions::Mesh::Runners::Delegation
- Includes:
- Helpers::Lex
- Included in:
- Client
- Defined in:
- lib/legion/extensions/mesh/runners/delegation.rb
Instance Method Summary collapse
- #agent_delegations(agent_id:, status: nil) ⇒ Object
- #complete_delegation(delegation_id:) ⇒ Object
- #delegate(from:, to:, task_context:, consent_level: :execute, parent_delegation_id: nil) ⇒ Object
- #delegation_chain(delegation_id:) ⇒ Object
- #delegation_stats ⇒ Object
- #revoke_delegation(delegation_id:) ⇒ Object
Instance Method Details
#agent_delegations(agent_id:, status: nil) ⇒ Object
47 48 49 50 |
# File 'lib/legion/extensions/mesh/runners/delegation.rb', line 47 def agent_delegations(agent_id:, status: nil, **) results = delegation_tracker.for_agent(agent_id, status: status&.to_sym) { success: true, delegations: results, count: results.size } end |
#complete_delegation(delegation_id:) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/legion/extensions/mesh/runners/delegation.rb', line 26 def complete_delegation(delegation_id:, **) result = delegation_tracker.complete(delegation_id) return { success: false, reason: :not_found_or_inactive } unless result publish_delegation_event('delegation.completed', result) { success: true, delegation_id: delegation_id } end |
#delegate(from:, to:, task_context:, consent_level: :execute, parent_delegation_id: nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/legion/extensions/mesh/runners/delegation.rb', line 12 def delegate(from:, to:, task_context:, consent_level: :execute, parent_delegation_id: nil, **) result = delegation_tracker.create( from: from, to: to, task_context: task_context, consent_level: .to_sym, parent_delegation_id: parent_delegation_id ) return { success: false, **result } if result[:error] publish_delegation_event('delegation.created', result) { success: true, delegation_id: result[:delegation_id], depth: result[:depth] } end |
#delegation_chain(delegation_id:) ⇒ Object
42 43 44 45 |
# File 'lib/legion/extensions/mesh/runners/delegation.rb', line 42 def delegation_chain(delegation_id:, **) chain = delegation_tracker.chain(delegation_id) { success: true, chain: chain, depth: [chain.size - 1, 0].max } end |
#delegation_stats ⇒ Object
52 53 54 |
# File 'lib/legion/extensions/mesh/runners/delegation.rb', line 52 def delegation_stats(**) delegation_tracker.stats.merge(success: true) end |
#revoke_delegation(delegation_id:) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/legion/extensions/mesh/runners/delegation.rb', line 34 def revoke_delegation(delegation_id:, **) result = delegation_tracker.revoke(delegation_id) return { success: false, reason: :not_found_or_inactive } unless result publish_delegation_event('delegation.revoked', result) { success: true, delegation_id: delegation_id } end |