Class: Protege::Toolkit
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Protege::Toolkit
- Includes:
- BroadcastableToolkit
- Defined in:
- app/models/protege/toolkit.rb
Overview
A toolkit — the first "Binding" of the extension framework. A global, dashboard-managed, reusable
bundle of tools (referenced by their manifest ids) and nothing more: it says what tools travel
together, not who may use them. Permission is a property of the attachment — see AgentToolkit —
so the same toolkit given to two agents can be gated differently, with no tool-list duplication.
Member tools are a member_tool_ids JSON id list (a checklist over the tool manifest), reconciled
against the live manifest at read time so a stale id (a tool since removed from the code) is skipped.
A toolkit may be a system toolkit — one the engine guarantees exists, identified by a stable key
rather than its (renameable) display name (see Protege::SystemToolkits). The all_tools system kit
is auto-maintained to hold every registered tool; default_tools is auto-attached to each new agent.
System toolkits can't be deleted from the dashboard. User-created toolkits leave key nil.
Constant Summary collapse
- ALL_TOOLS_KEY =
The stable key of the auto-maintained toolkit holding every registered tool.
'all_tools'- DEFAULT_TOOLS_KEY =
The stable key of the toolkit auto-attached to every new agent.
'default_tools'
Constants included from BroadcastableToolkit
Class Method Summary collapse
-
.all_tools ⇒ Protege::Toolkit?
The auto-maintained "All Tools" system toolkit, or nil before it has been synced.
-
.default_tools ⇒ Protege::Toolkit?
The "Default Tools" system toolkit auto-attached to new agents, or nil before it has been synced.
Instance Method Summary collapse
-
#covers?(tool_id) ⇒ Boolean
Whether this toolkit includes a given tool id.
-
#member_tools ⇒ Array<Protege::Manifest::Entry>
The member tools that still exist, as manifest entries — stale ids (naming a removed tool) are dropped, so a toolkit tolerates a member whose tool has since been deleted from the code.
-
#system? ⇒ Boolean
Whether this is an engine-managed system toolkit (carries a
key) — such toolkits can't be deleted, andall_toolshas its membership maintained by the engine rather than the operator.
Class Method Details
.all_tools ⇒ Protege::Toolkit?
The auto-maintained "All Tools" system toolkit, or nil before it has been synced.
55 56 57 |
# File 'app/models/protege/toolkit.rb', line 55 def all_tools find_by(key: ALL_TOOLS_KEY) end |
.default_tools ⇒ Protege::Toolkit?
The "Default Tools" system toolkit auto-attached to new agents, or nil before it has been synced.
62 63 64 |
# File 'app/models/protege/toolkit.rb', line 62 def default_tools find_by(key: DEFAULT_TOOLS_KEY) end |
Instance Method Details
#covers?(tool_id) ⇒ Boolean
Whether this toolkit includes a given tool id.
81 82 83 |
# File 'app/models/protege/toolkit.rb', line 81 def covers?(tool_id) member_tool_ids.map(&:to_sym).include?(tool_id.to_sym) end |
#member_tools ⇒ Array<Protege::Manifest::Entry>
The member tools that still exist, as manifest entries — stale ids (naming a removed tool) are dropped, so a toolkit tolerates a member whose tool has since been deleted from the code.
89 90 91 92 |
# File 'app/models/protege/toolkit.rb', line 89 def member_tools ids = member_tool_ids.map(&:to_sym) Manifest.registered(:tool).select { |entry| ids.include?(entry.id) } end |
#system? ⇒ Boolean
Whether this is an engine-managed system toolkit (carries a key) — such toolkits can't be deleted,
and all_tools has its membership maintained by the engine rather than the operator.
73 74 75 |
# File 'app/models/protege/toolkit.rb', line 73 def system? key.present? end |