Class: SignalWire::Skills::SkillBase
- Inherits:
-
Object
- Object
- SignalWire::Skills::SkillBase
- Defined in:
- lib/signalwire/skills/skill_base.rb
Overview
Base class for all skills. Subclasses override the metadata methods and register_tools to supply tool hashes.
Direct Known Subclasses
Builtin::ApiNinjasTriviaSkill, Builtin::ClaudeSkillsSkill, Builtin::CustomSkillsSkill, Builtin::DatasphereServerlessSkill, Builtin::DatasphereSkill, Builtin::DateTimeSkill, Builtin::GoogleMapsSkill, Builtin::InfoGathererSkill, Builtin::JokeSkill, Builtin::MathSkill, Builtin::McpGatewaySkill, Builtin::NativeVectorSearchSkill, Builtin::PlayBackgroundFileSkill, Builtin::SpiderSkill, Builtin::SwmlTransferSkill, Builtin::WeatherApiSkill, Builtin::WebSearchSkill, Builtin::WikipediaSearchSkill
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Python parity: - “params“ — params hash passed at construction - “agent“ — owning AgentBase instance (or nil for standalone) - “logger“ — namespaced logger “signalwire.skills.<name>“ - “swaig_fields“ — extra SWAIG fields merged into tool defs; pulled out of “params“ if provided.
-
#logger ⇒ Object
readonly
Python parity: - “params“ — params hash passed at construction - “agent“ — owning AgentBase instance (or nil for standalone) - “logger“ — namespaced logger “signalwire.skills.<name>“ - “swaig_fields“ — extra SWAIG fields merged into tool defs; pulled out of “params“ if provided.
-
#params ⇒ Object
readonly
Python parity: - “params“ — params hash passed at construction - “agent“ — owning AgentBase instance (or nil for standalone) - “logger“ — namespaced logger “signalwire.skills.<name>“ - “swaig_fields“ — extra SWAIG fields merged into tool defs; pulled out of “params“ if provided.
-
#swaig_fields ⇒ Object
readonly
Python parity: - “params“ — params hash passed at construction - “agent“ — owning AgentBase instance (or nil for standalone) - “logger“ — namespaced logger “signalwire.skills.<name>“ - “swaig_fields“ — extra SWAIG fields merged into tool defs; pulled out of “params“ if provided.
Instance Method Summary collapse
-
#cleanup ⇒ Object
Called when the skill is unloaded.
- #description ⇒ Object
-
#get_global_data ⇒ Object
Global data to merge into the agent.
-
#get_hints ⇒ Object
Speech recognition hints.
-
#get_param(key, env_var: nil, default: nil) ⇒ Object
Helper to get a param with env-var fallback.
-
#get_parameter_schema ⇒ Object
Parameter schema for GUI / validation.
-
#get_prompt_sections ⇒ Object
Prompt sections to add to the agent.
-
#initialize(agent = nil, params = nil) ⇒ SkillBase
constructor
Python parity: “SkillBase.__init__(self, agent, params=None)“.
-
#instance_key ⇒ Object
Unique key for tracking this skill instance.
- #name ⇒ Object
-
#register_tools ⇒ Object
Return an Array of tool definition hashes.
- #required_env_vars ⇒ Object
-
#setup ⇒ Object
Called once after construction.
- #supports_multiple_instances? ⇒ Boolean
- #version ⇒ Object
Constructor Details
#initialize(agent = nil, params = nil) ⇒ SkillBase
Python parity: “SkillBase.__init__(self, agent, params=None)“. First positional arg is the owning AgentBase (or nil for standalone). The second is the params hash. We accept the legacy 1-arg form for backwards compatibility (“DateTimeSkill.new(…)“).
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/signalwire/skills/skill_base.rb', line 34 def initialize(agent = nil, params = nil) # Backwards compat: a single Hash means params-only (no agent). if agent.is_a?(Hash) && params.nil? params = agent agent = nil end @agent = agent @params = (params || {}).transform_keys(&:to_s) # Python: pop swaig_fields out of params for separate access. @swaig_fields = @params.delete('swaig_fields') || {} @logger = ::SignalWire::Logging.logger("signalwire.skills.#{begin name rescue NotImplementedError self.class.name end}") end |
Instance Attribute Details
#agent ⇒ Object (readonly)
Python parity:
-
“params“ — params hash passed at construction
-
“agent“ — owning AgentBase instance (or nil for standalone)
-
“logger“ — namespaced logger “signalwire.skills.<name>“
-
“swaig_fields“ — extra SWAIG fields merged into tool defs; pulled out of “params“ if provided
22 23 24 |
# File 'lib/signalwire/skills/skill_base.rb', line 22 def agent @agent end |
#logger ⇒ Object (readonly)
Python parity:
-
“params“ — params hash passed at construction
-
“agent“ — owning AgentBase instance (or nil for standalone)
-
“logger“ — namespaced logger “signalwire.skills.<name>“
-
“swaig_fields“ — extra SWAIG fields merged into tool defs; pulled out of “params“ if provided
22 23 24 |
# File 'lib/signalwire/skills/skill_base.rb', line 22 def logger @logger end |
#params ⇒ Object (readonly)
Python parity:
-
“params“ — params hash passed at construction
-
“agent“ — owning AgentBase instance (or nil for standalone)
-
“logger“ — namespaced logger “signalwire.skills.<name>“
-
“swaig_fields“ — extra SWAIG fields merged into tool defs; pulled out of “params“ if provided
22 23 24 |
# File 'lib/signalwire/skills/skill_base.rb', line 22 def params @params end |
#swaig_fields ⇒ Object (readonly)
Python parity:
-
“params“ — params hash passed at construction
-
“agent“ — owning AgentBase instance (or nil for standalone)
-
“logger“ — namespaced logger “signalwire.skills.<name>“
-
“swaig_fields“ — extra SWAIG fields merged into tool defs; pulled out of “params“ if provided
22 23 24 |
# File 'lib/signalwire/skills/skill_base.rb', line 22 def swaig_fields @swaig_fields end |
Instance Method Details
#cleanup ⇒ Object
Called when the skill is unloaded.
68 |
# File 'lib/signalwire/skills/skill_base.rb', line 68 def cleanup; end |
#description ⇒ Object
25 |
# File 'lib/signalwire/skills/skill_base.rb', line 25 def description; raise NotImplementedError, "#{self.class}#description"; end |
#get_global_data ⇒ Object
Global data to merge into the agent.
62 |
# File 'lib/signalwire/skills/skill_base.rb', line 62 def get_global_data; {}; end |
#get_hints ⇒ Object
Speech recognition hints.
59 |
# File 'lib/signalwire/skills/skill_base.rb', line 59 def get_hints; []; end |
#get_param(key, env_var: nil, default: nil) ⇒ Object
Helper to get a param with env-var fallback.
77 78 79 |
# File 'lib/signalwire/skills/skill_base.rb', line 77 def get_param(key, env_var: nil, default: nil) @params[key.to_s] || @params[key.to_sym.to_s] || (env_var && ENV[env_var]) || default end |
#get_parameter_schema ⇒ Object
Parameter schema for GUI / validation.
74 |
# File 'lib/signalwire/skills/skill_base.rb', line 74 def get_parameter_schema; {}; end |
#get_prompt_sections ⇒ Object
Prompt sections to add to the agent.
65 |
# File 'lib/signalwire/skills/skill_base.rb', line 65 def get_prompt_sections; []; end |
#instance_key ⇒ Object
Unique key for tracking this skill instance.
71 |
# File 'lib/signalwire/skills/skill_base.rb', line 71 def instance_key; name; end |
#name ⇒ Object
24 |
# File 'lib/signalwire/skills/skill_base.rb', line 24 def name; raise NotImplementedError, "#{self.class}#name"; end |
#register_tools ⇒ Object
Return an Array of tool definition hashes. Each hash should have:
:name, :description, :parameters, :handler (lambda/proc)
56 |
# File 'lib/signalwire/skills/skill_base.rb', line 56 def register_tools; []; end |
#required_env_vars ⇒ Object
27 |
# File 'lib/signalwire/skills/skill_base.rb', line 27 def required_env_vars; []; end |
#setup ⇒ Object
Called once after construction. Return true if the skill is ready.
52 |
# File 'lib/signalwire/skills/skill_base.rb', line 52 def setup; true; end |
#supports_multiple_instances? ⇒ Boolean
28 |
# File 'lib/signalwire/skills/skill_base.rb', line 28 def supports_multiple_instances?; false; end |
#version ⇒ Object
26 |
# File 'lib/signalwire/skills/skill_base.rb', line 26 def version; '1.0.0'; end |