« blib/lib/SignalWire/Agents/REST/Namespaces/Fabric.pm
↑ Summary
blib/lib/SignalWire/Agents/Skills/Builtin/Math.pm »
| 1 | package SignalWire::Agents::Skills::Builtin::PlayBackgroundFile; | ||||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 3 | ▶ | use Moo; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 3 | extends 'SignalWire::Agents::Skills::SkillBase'; | |||||||||||
| 6 | |||||||||||||
| 7 | 3 | ▶ | use SignalWire::Agents::Skills::SkillRegistry; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 3 | SignalWire::Agents::Skills::SkillRegistry->register_skill('play_background_file', __PACKAGE__); | |||||||||||
| 9 | |||||||||||||
| 10 | 5 | ▶ | has '+skill_name' => (default => sub { 'play_background_file' }); | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | 5 | ▶ | has '+skill_description' => (default => sub { 'Control background file playback' }); | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 12 | 5 | ▶ | has '+supports_multiple_instances' => (default => sub { 1 }); | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 13 | |||||||||||||
| 14 | 4 | ▶ | sub setup { 1 } | ||||||||||
|
Subroutine
setup: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 15 | |||||||||||||
| 16 | 3 | ▶ | sub register_tools { | ||||||||||
|
Subroutine
register_tools: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||
| 17 | 3 | my ($self) = @_; | |||||||||||
| 18 | 3 | ▶ | my $tool_name = $self->params->{tool_name} // 'play_background_file'; | ||||||||||
|
Condition100%2/2
$self->params->{"tool_name"} // "play_background_file"
MC/DC100%1/1
$self->params->{"tool_name"} // "play_background_file"
$self->params->{"tool_name"}
Truth table100%2/2
A
A= $self->params->{"tool_name"}
| |||||||||||||
| 19 | 3 | ▶ | my $files = $self->params->{files} // []; | ||||||||||
|
Condition100%2/2
$self->params->{"files"} // []
MC/DC100%1/1
$self->params->{"files"} // []
$self->params->{"files"}
Truth table100%2/2
A
A= $self->params->{"files"}
| |||||||||||||
| 20 | |||||||||||||
| 21 | # Build action enum from file keys | ||||||||||||
| 22 | 3 | my @actions = ('stop'); | |||||||||||
| 23 | 3 | for my $f (@$files) { | |||||||||||
| 24 | 2 | ▶ | push @actions, "start_$f->{key}" if $f->{key}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 25 | } | ||||||||||||
| 26 | |||||||||||||
| 27 | # DataMap-style registration with expressions | ||||||||||||
| 28 | $self->agent->register_swaig_function({ | ||||||||||||
| 29 | 3 | function => $tool_name, | |||||||||||
| 30 | description => "Control background file playback for $tool_name", | ||||||||||||
| 31 | parameters => { | ||||||||||||
| 32 | type => 'object', | ||||||||||||
| 33 | properties => { | ||||||||||||
| 34 | action => { | ||||||||||||
| 35 | type => 'string', | ||||||||||||
| 36 | description => 'Playback action', | ||||||||||||
| 37 | enum => \@actions, | ||||||||||||
| 38 | }, | ||||||||||||
| 39 | }, | ||||||||||||
| 40 | required => ['action'], | ||||||||||||
| 41 | }, | ||||||||||||
| 42 | data_map => { | ||||||||||||
| 43 | expressions => [ | ||||||||||||
| 44 | { | ||||||||||||
| 45 | string => '${args.action}', | ||||||||||||
| 46 | pattern => 'stop', | ||||||||||||
| 47 | output => { | ||||||||||||
| 48 | response => 'Stopping background playback.', | ||||||||||||
| 49 | action => [{ stop_background_file => {} }], | ||||||||||||
| 50 | }, | ||||||||||||
| 51 | }, | ||||||||||||
| 52 | ], | ||||||||||||
| 53 | }, | ||||||||||||
| 54 | }); | ||||||||||||
| 55 | } | ||||||||||||
| 56 | |||||||||||||
| 57 | 1 | ▶ | sub get_parameter_schema { | ||||||||||
|
Subroutine
get_parameter_schema: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 58 | return { | ||||||||||||
| 59 | 1 | %{ SignalWire::Agents::Skills::SkillBase->get_parameter_schema }, | |||||||||||
| 60 | files => { type => 'array', required => 1, description => 'Array of file objects with key, description, url' }, | ||||||||||||
| 61 | tool_name => { type => 'string', default => 'play_background_file' }, | ||||||||||||
| 62 | }; | ||||||||||||
| 63 | } | ||||||||||||
| 64 | |||||||||||||
| 65 | 3 | 1; | |||||||||||