Class: Legion::Extensions::Agentic::Executive::ProspectiveMemory::Helpers::Intention
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Executive::ProspectiveMemory::Helpers::Intention
- Defined in:
- lib/legion/extensions/agentic/executive/prospective_memory/helpers/intention.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#executed_at ⇒ Object
readonly
Returns the value of attribute executed_at.
-
#expires_at ⇒ Object
readonly
Returns the value of attribute expires_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#trigger_condition ⇒ Object
readonly
Returns the value of attribute trigger_condition.
-
#trigger_type ⇒ Object
readonly
Returns the value of attribute trigger_type.
-
#triggered_at ⇒ Object
readonly
Returns the value of attribute triggered_at.
-
#urgency ⇒ Object
Returns the value of attribute urgency.
Instance Method Summary collapse
- #boost_urgency!(amount: Constants::URGENCY_BOOST) ⇒ Object
- #cancel! ⇒ Object
- #decay_urgency! ⇒ Object
- #execute! ⇒ Object
- #expire! ⇒ Object
- #expired? ⇒ Boolean
-
#initialize(description:, trigger_type:, trigger_condition:, urgency: Constants::DEFAULT_URGENCY, domain: nil, expires_at: nil) ⇒ Intention
constructor
A new instance of Intention.
- #monitor! ⇒ Object
- #to_h ⇒ Object
- #trigger! ⇒ Object
- #urgency_label ⇒ Object
Constructor Details
#initialize(description:, trigger_type:, trigger_condition:, urgency: Constants::DEFAULT_URGENCY, domain: nil, expires_at: nil) ⇒ Intention
Returns a new instance of Intention.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/legion/extensions/agentic/executive/prospective_memory/helpers/intention.rb', line 17 def initialize(description:, trigger_type:, trigger_condition:, urgency: Constants::DEFAULT_URGENCY, domain: nil, expires_at: nil) @id = SecureRandom.uuid @description = description @trigger_type = trigger_type @trigger_condition = trigger_condition @urgency = urgency.clamp(0.0, 1.0) @domain = domain @status = :pending @created_at = Time.now.utc @triggered_at = nil @executed_at = nil @expires_at = expires_at end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/executive/prospective_memory/helpers/intention.rb', line 12 def created_at @created_at end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
12 13 14 |
# File 'lib/legion/extensions/agentic/executive/prospective_memory/helpers/intention.rb', line 12 def description @description end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
12 13 14 |
# File 'lib/legion/extensions/agentic/executive/prospective_memory/helpers/intention.rb', line 12 def domain @domain end |
#executed_at ⇒ Object (readonly)
Returns the value of attribute executed_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/executive/prospective_memory/helpers/intention.rb', line 12 def executed_at @executed_at end |
#expires_at ⇒ Object (readonly)
Returns the value of attribute expires_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/executive/prospective_memory/helpers/intention.rb', line 12 def expires_at @expires_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/legion/extensions/agentic/executive/prospective_memory/helpers/intention.rb', line 12 def id @id end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
12 13 14 |
# File 'lib/legion/extensions/agentic/executive/prospective_memory/helpers/intention.rb', line 12 def status @status end |
#trigger_condition ⇒ Object (readonly)
Returns the value of attribute trigger_condition.
12 13 14 |
# File 'lib/legion/extensions/agentic/executive/prospective_memory/helpers/intention.rb', line 12 def trigger_condition @trigger_condition end |
#trigger_type ⇒ Object (readonly)
Returns the value of attribute trigger_type.
12 13 14 |
# File 'lib/legion/extensions/agentic/executive/prospective_memory/helpers/intention.rb', line 12 def trigger_type @trigger_type end |
#triggered_at ⇒ Object (readonly)
Returns the value of attribute triggered_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/executive/prospective_memory/helpers/intention.rb', line 12 def triggered_at @triggered_at end |
#urgency ⇒ Object
Returns the value of attribute urgency.
15 16 17 |
# File 'lib/legion/extensions/agentic/executive/prospective_memory/helpers/intention.rb', line 15 def urgency @urgency end |
Instance Method Details
#boost_urgency!(amount: Constants::URGENCY_BOOST) ⇒ Object
60 61 62 |
# File 'lib/legion/extensions/agentic/executive/prospective_memory/helpers/intention.rb', line 60 def boost_urgency!(amount: Constants::URGENCY_BOOST) @urgency = (@urgency + amount).clamp(0.0, 1.0).round(10) end |
#cancel! ⇒ Object
50 51 52 |
# File 'lib/legion/extensions/agentic/executive/prospective_memory/helpers/intention.rb', line 50 def cancel! @status = :cancelled end |
#decay_urgency! ⇒ Object
64 65 66 |
# File 'lib/legion/extensions/agentic/executive/prospective_memory/helpers/intention.rb', line 64 def decay_urgency! @urgency = (@urgency - Constants::URGENCY_DECAY).clamp(0.0, 1.0).round(10) end |
#execute! ⇒ Object
41 42 43 44 |
# File 'lib/legion/extensions/agentic/executive/prospective_memory/helpers/intention.rb', line 41 def execute! @status = :executed @executed_at = Time.now.utc end |
#expire! ⇒ Object
46 47 48 |
# File 'lib/legion/extensions/agentic/executive/prospective_memory/helpers/intention.rb', line 46 def expire! @status = :expired end |
#expired? ⇒ Boolean
54 55 56 57 58 |
# File 'lib/legion/extensions/agentic/executive/prospective_memory/helpers/intention.rb', line 54 def expired? return false unless @expires_at Time.now.utc > @expires_at end |
#monitor! ⇒ Object
32 33 34 |
# File 'lib/legion/extensions/agentic/executive/prospective_memory/helpers/intention.rb', line 32 def monitor! @status = :monitoring end |
#to_h ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/legion/extensions/agentic/executive/prospective_memory/helpers/intention.rb', line 72 def to_h { id: @id, description: @description, trigger_type: @trigger_type, trigger_condition: @trigger_condition, urgency: @urgency, urgency_label: urgency_label, status: @status, domain: @domain, created_at: @created_at, triggered_at: @triggered_at, executed_at: @executed_at, expires_at: @expires_at } end |
#trigger! ⇒ Object
36 37 38 39 |
# File 'lib/legion/extensions/agentic/executive/prospective_memory/helpers/intention.rb', line 36 def trigger! @status = :triggered @triggered_at = Time.now.utc end |
#urgency_label ⇒ Object
68 69 70 |
# File 'lib/legion/extensions/agentic/executive/prospective_memory/helpers/intention.rb', line 68 def urgency_label Constants::URGENCY_LABELS.find { |range, _label| range.cover?(@urgency) }&.last || :deferred end |