Class: Protege::AgentToolkit
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Protege::AgentToolkit
- Defined in:
- app/models/protege/agent_toolkit.rb
Overview
The grant binding one Toolkit to one Agent — and where the toolkit's permission lives. Giving a
toolkit to an agent is not just "these tools are available"; it is "these tools are available to the
senders I allow here". So the attachment carries the sender gate (its agent_toolkit_rules folded
into a Gateway::AccessPolicy, mirroring AccessRule) and allow_proactive (whether the tools may
run on this agent's scheduled, senderless runs). Two agents can attach the same toolkit and gate it
differently.
Instance Method Summary collapse
-
#access_policy ⇒ Protege::Gateway::AccessPolicy
The sender gate for this grant as a policy, folded from its rules through the Gateway factory (never constructed by hand), mirroring
AccessRule.policy_for. -
#permits?(sender:) ⇒ Boolean
Whether a sender may unlock this grant's tools, per its gate.
Instance Method Details
#access_policy ⇒ Protege::Gateway::AccessPolicy
The sender gate for this grant as a policy, folded from its rules through the Gateway factory (never
constructed by hand), mirroring AccessRule.policy_for. A grant with no rules permits everyone.
34 35 36 37 38 39 40 |
# File 'app/models/protege/agent_toolkit.rb', line 34 def access_policy grouped = agent_toolkit_rules.group_by(&:kind) Gateway.build_access_policy( allow: Array(grouped['allow']).map(&:pattern), deny: Array(grouped['deny']).map(&:pattern) ) end |
#permits?(sender:) ⇒ Boolean
Whether a sender may unlock this grant's tools, per its gate.
46 47 48 |
# File 'app/models/protege/agent_toolkit.rb', line 46 def permits?(sender:) access_policy.permits?(address: sender) end |