File Coverage

blib/lib/SignalWire/Agents/Skills/Builtin/CustomSkills.pm
Criterion Covered Total %
statement 22 22 100.0
branch 5 6 83.3
condition 2 2 100.0
subroutine 7 7 100.0
pod 0 3 0.0
total 36 40 90.0


line stmt bran cond sub pod time code
1             package SignalWire::Agents::Skills::Builtin::CustomSkills;
2 3     3   22 use strict;
  3         6  
  3         129  
3 3     3   15 use warnings;
  3         5  
  3         205  
4 3     3   20 use Moo;
  3         5  
  3         22  
5             extends 'SignalWire::Agents::Skills::SkillBase';
6              
7 3     3   1366 use SignalWire::Agents::Skills::SkillRegistry;
  3         22  
  3         1105  
8             SignalWire::Agents::Skills::SkillRegistry->register_skill('custom_skills', __PACKAGE__);
9              
10             has '+skill_name' => (default => sub { 'custom_skills' });
11             has '+skill_description' => (default => sub { 'Register user-defined custom tools' });
12             has '+supports_multiple_instances' => (default => sub { 1 });
13              
14 7     7 0 2343 sub setup { 1 }
15              
16             sub register_tools {
17 6     6 0 542 my ($self) = @_;
18 6   100     30 my $tools = $self->params->{tools} // [];
19              
20 6         17 for my $tool_def (@$tools) {
21 7 100       16 next unless ref $tool_def eq 'HASH';
22 5 100       14 if (exists $tool_def->{function}) {
    50          
23 2         9 $self->agent->register_swaig_function($tool_def);
24             } elsif (exists $tool_def->{name}) {
25 3         21 $self->agent->define_tool(%$tool_def);
26             }
27             }
28             }
29              
30             sub get_parameter_schema {
31             return {
32 1     1 0 3361 %{ SignalWire::Agents::Skills::SkillBase->get_parameter_schema },
  1         6  
33             tools => { type => 'array', description => 'Array of tool definition objects' },
34             };
35             }
36              
37             1;