Class: Legion::Tools::Base
- Inherits:
-
Object
- Object
- Legion::Tools::Base
show all
- Defined in:
- lib/legion/tools/base.rb
Direct Known Subclasses
CLI::Chat::Tools::ArbitrageStatus, CLI::Chat::Tools::BudgetStatus, CLI::Chat::Tools::ConsolidateMemory, CLI::Chat::Tools::CostSummary, CLI::Chat::Tools::DetectAnomalies, CLI::Chat::Tools::EditFile, CLI::Chat::Tools::EntityExtract, CLI::Chat::Tools::EscalationStatus, CLI::Chat::Tools::GenerateInsights, CLI::Chat::Tools::GraphExplore, CLI::Chat::Tools::IngestKnowledge, CLI::Chat::Tools::KnowledgeMaintenance, CLI::Chat::Tools::KnowledgeStats, CLI::Chat::Tools::ListExtensions, CLI::Chat::Tools::ManageSchedules, CLI::Chat::Tools::ManageTasks, CLI::Chat::Tools::MemoryStatus, CLI::Chat::Tools::ModelComparison, CLI::Chat::Tools::ProviderHealth, CLI::Chat::Tools::QueryKnowledge, CLI::Chat::Tools::ReadFile, CLI::Chat::Tools::Reflect, CLI::Chat::Tools::RelateKnowledge, CLI::Chat::Tools::RunCommand, CLI::Chat::Tools::SaveMemory, CLI::Chat::Tools::SchedulingStatus, CLI::Chat::Tools::SearchContent, CLI::Chat::Tools::SearchFiles, CLI::Chat::Tools::SearchMemory, CLI::Chat::Tools::SearchTraces, CLI::Chat::Tools::ShadowEvalStatus, CLI::Chat::Tools::SpawnAgent, CLI::Chat::Tools::SummarizeTraces, CLI::Chat::Tools::SystemStatus, CLI::Chat::Tools::TriggerDream, CLI::Chat::Tools::ViewEvents, CLI::Chat::Tools::ViewTrends, CLI::Chat::Tools::WebSearch, CLI::Chat::Tools::WorkerStatus, CLI::Chat::Tools::WriteFile, Config, Do, Status
Class Method Summary
collapse
Class Method Details
.call(**_args) ⇒ Object
84
85
86
|
# File 'lib/legion/tools/base.rb', line 84
def call(**_args)
raise NotImplementedError, "#{name} must implement .call"
end
|
.deferred(val = nil) ⇒ Object
31
32
33
34
35
|
# File 'lib/legion/tools/base.rb', line 31
def deferred(val = nil)
return @deferred || false if val.nil?
@deferred = val
end
|
.deferred? ⇒ Boolean
37
38
39
|
# File 'lib/legion/tools/base.rb', line 37
def deferred?
deferred
end
|
.description(desc = nil) ⇒ Object
23
24
25
|
# File 'lib/legion/tools/base.rb', line 23
def description(desc = nil)
desc ? @description = desc : (@description || '')
end
|
.error_response(msg) ⇒ Object
93
94
95
|
# File 'lib/legion/tools/base.rb', line 93
def error_response(msg)
{ content: [{ type: 'text', text: Legion::JSON.dump({ error: msg }) }], error: true }
end
|
.extension(val = nil) ⇒ Object
Metadata that replaces Capability - Tools::Registry IS the catalog
42
43
44
45
46
|
# File 'lib/legion/tools/base.rb', line 42
def extension(val = nil)
return @extension if val.nil?
@extension = val
end
|
.handle_exception(err, **opts) ⇒ Object
15
16
17
|
# File 'lib/legion/tools/base.rb', line 15
def handle_exception(err, **opts)
log&.warn("[Legion::Tools] #{opts[:operation] || 'unknown'}: #{err.message}")
end
|
27
28
29
|
# File 'lib/legion/tools/base.rb', line 27
def input_schema(schema = nil)
schema ? @input_schema = schema : @input_schema
end
|
.log ⇒ Object
Lazy delegation instead of include Helper — Base loads at require time before Settings is initialized; Helper#log builds TaggedLogger which calls derive_log_segments -> Settings -> possible recursion. Subclass static tools (Do, Status, Config) CAN include Helper safely.
11
12
13
|
# File 'lib/legion/tools/base.rb', line 11
def log
Legion::Logging.respond_to?(:logger) ? Legion::Logging.logger : nil
end
|
.mcp_category(val = nil) ⇒ Object
60
61
62
63
64
|
# File 'lib/legion/tools/base.rb', line 60
def mcp_category(val = nil)
return @mcp_category if val.nil?
@mcp_category = val
end
|
.mcp_tier(val = nil) ⇒ Object
66
67
68
69
70
|
# File 'lib/legion/tools/base.rb', line 66
def mcp_tier(val = nil)
return @mcp_tier if val.nil?
@mcp_tier = val
end
|
.runner(val = nil) ⇒ Object
48
49
50
51
52
|
# File 'lib/legion/tools/base.rb', line 48
def runner(val = nil)
return @runner if val.nil?
@runner = val
end
|
.sticky(val = nil) ⇒ Object
78
79
80
81
82
|
# File 'lib/legion/tools/base.rb', line 78
def sticky(val = nil)
return @sticky.nil? || @sticky if val.nil?
@sticky = val
end
|
54
55
56
57
58
|
# File 'lib/legion/tools/base.rb', line 54
def tags(val = nil)
return @tags || [] if val.nil?
@tags = val
end
|
.text_response(data) ⇒ Object
88
89
90
91
|
# File 'lib/legion/tools/base.rb', line 88
def text_response(data)
text = data.is_a?(String) ? data : Legion::JSON.dump(data)
{ content: [{ type: 'text', text: text }] }
end
|
19
20
21
|
# File 'lib/legion/tools/base.rb', line 19
def tool_name(name = nil)
name ? @tool_name = name : @tool_name
end
|
.trigger_words(val = nil) ⇒ Object
72
73
74
75
76
|
# File 'lib/legion/tools/base.rb', line 72
def trigger_words(val = nil)
return @trigger_words || [] if val.nil?
@trigger_words = val
end
|