Class: Legion::Isolation::Context
- Inherits:
-
Object
- Object
- Legion::Isolation::Context
- Defined in:
- lib/legion/isolation.rb
Instance Attribute Summary collapse
-
#agent_id ⇒ Object
readonly
Returns the value of attribute agent_id.
-
#allowed_tools ⇒ Object
readonly
Returns the value of attribute allowed_tools.
-
#risk_tier ⇒ Object
readonly
Returns the value of attribute risk_tier.
-
#tenant_id ⇒ Object
readonly
Returns the value of attribute tenant_id.
Instance Method Summary collapse
- #data_filter ⇒ Object
-
#initialize(agent_id:, tenant_id: nil, allowed_tools: [], risk_tier: :standard) ⇒ Context
constructor
A new instance of Context.
- #tool_allowed?(tool_name) ⇒ Boolean
Constructor Details
#initialize(agent_id:, tenant_id: nil, allowed_tools: [], risk_tier: :standard) ⇒ Context
Returns a new instance of Context.
8 9 10 11 12 13 |
# File 'lib/legion/isolation.rb', line 8 def initialize(agent_id:, tenant_id: nil, allowed_tools: [], risk_tier: :standard) @agent_id = agent_id @tenant_id = tenant_id @allowed_tools = allowed_tools.map(&:to_s).freeze @risk_tier = risk_tier.to_sym end |
Instance Attribute Details
#agent_id ⇒ Object (readonly)
Returns the value of attribute agent_id.
6 7 8 |
# File 'lib/legion/isolation.rb', line 6 def agent_id @agent_id end |
#allowed_tools ⇒ Object (readonly)
Returns the value of attribute allowed_tools.
6 7 8 |
# File 'lib/legion/isolation.rb', line 6 def allowed_tools @allowed_tools end |
#risk_tier ⇒ Object (readonly)
Returns the value of attribute risk_tier.
6 7 8 |
# File 'lib/legion/isolation.rb', line 6 def risk_tier @risk_tier end |
#tenant_id ⇒ Object (readonly)
Returns the value of attribute tenant_id.
6 7 8 |
# File 'lib/legion/isolation.rb', line 6 def tenant_id @tenant_id end |
Instance Method Details
#data_filter ⇒ Object
19 20 21 22 23 |
# File 'lib/legion/isolation.rb', line 19 def data_filter filter = { agent_id: agent_id } filter[:tenant_id] = tenant_id if tenant_id filter end |
#tool_allowed?(tool_name) ⇒ Boolean
15 16 17 |
# File 'lib/legion/isolation.rb', line 15 def tool_allowed?(tool_name) allowed_tools.empty? || allowed_tools.include?(tool_name.to_s) end |