Class: Legion::Isolation::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/isolation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_idObject (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_toolsObject (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_tierObject (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_idObject (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_filterObject



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

Returns:

  • (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